]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG: only put if we cancel evt in unregister_unconnected_watcher
authorSamuel Just <sam.just@inktank.com>
Wed, 12 Dec 2012 22:26:59 +0000 (14:26 -0800)
committerSamuel Just <sam.just@inktank.com>
Wed, 12 Dec 2012 22:50:18 +0000 (14:50 -0800)
If we fail to cancel the callback, the callback will fire and
release those resources.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/ReplicatedPG.cc

index e6152678ed11c79f2bf21e3fb3f1e70058fc6287..f3c6e57a77a90d83b802570f3be33288b548e136 100644 (file)
@@ -4116,10 +4116,14 @@ void ReplicatedPG::unregister_unconnected_watcher(void *_obc,
                                                  entity_name_t entity)
 {
   ObjectContext *obc = static_cast<ObjectContext *>(_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,