]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
sharedptr_registry.hpp: removed ptrs need to not blast contents
authorSamuel Just <sam.just@inktank.com>
Thu, 31 Oct 2013 20:19:32 +0000 (13:19 -0700)
committerSage Weil <sage@inktank.com>
Fri, 1 Nov 2013 23:02:21 +0000 (16:02 -0700)
commit28e4271267976ab8405a24d015f2fb50a2f82c49
tree4c67d98c6d7d197fac0f52ea8a5a08c96118406b
parent4402898390a9d9c8cb296ea05ac7c75f2c32a528
sharedptr_registry.hpp: removed ptrs need to not blast contents

See the included unit test update.  Consider:
1) x = lookup_or_create(1, 1)
2) remove(1)
3) y = lookup_or_create(1, 2)
4) x.reset()
5) z = lookup(1)

The bug is that z will be null since x.reset() caused the
cleanup callback to remove y's key value from contents.

To fix this, contents also records the pointer value for
the weak_ptr.  The removal callback only removes the
key from contents if it matches the ptr in contents.

This should work since the pointer passed to the removal
callback must be unique up to that point since it has
not yet been deleted.

This allowed a pg removal -> pg recreation -> pg removal
sequence to cause the second pg removal entry to be
erroneously cleared by the first pg removal's destructor
as it finally made its way through the removal queue.

Fixes: #5951
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/common/sharedptr_registry.hpp
src/test/common/test_sharedptr_registry.cc