]> 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)
committerSamuel Just <sam.just@inktank.com>
Fri, 19 Sep 2014 22:58:26 +0000 (15:58 -0700)
commitbddeb954bd38e58a2dec518d3e3f11234b0cd3a3
tree543e551a9f0dbcc04bc9b06f1429cf362a89d86c
parent49e8e466bd68a7381ee4547d2b8ea872b9a96fab
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>
(cherry picked from commit 28e4271267976ab8405a24d015f2fb50a2f82c49)
src/common/sharedptr_registry.hpp
src/test/common/test_sharedptr_registry.cc