If we fail to cancel the callback, the callback will fire and
release those resources.
Signed-off-by: Samuel Just <sam.just@inktank.com>
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,