From: Samuel Just Date: Wed, 12 Dec 2012 22:26:59 +0000 (-0800) Subject: ReplicatedPG: only put if we cancel evt in unregister_unconnected_watcher X-Git-Tag: v0.56~51^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=695bb3b0e26d4ccf43ac409a347304a189661922;p=ceph.git ReplicatedPG: only put if we cancel evt in unregister_unconnected_watcher If we fail to cancel the callback, the callback will fire and release those resources. Signed-off-by: Samuel Just --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index e6152678ed11..f3c6e57a77a9 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4116,10 +4116,14 @@ void ReplicatedPG::unregister_unconnected_watcher(void *_obc, entity_name_t entity) { ObjectContext *obc = static_cast(_obc); - osd->watch_timer.cancel_event(obc->unconnected_watchers[entity]); + + /* If we failed to cancel the event, the event will fire and the obc + * ref and the pg ref will be taken care of */ + if (osd->watch_timer.cancel_event(obc->unconnected_watchers[entity])) { + put_object_context(obc); + put(); + } obc->unconnected_watchers.erase(entity); - put_object_context(obc); - put(); } void ReplicatedPG::register_unconnected_watcher(void *_obc,