diff --git a/src/ifmap/ifmap_exporter.cc b/src/ifmap/ifmap_exporter.cc index ac47dd519ac..53ed297225c 100644 --- a/src/ifmap/ifmap_exporter.cc +++ b/src/ifmap/ifmap_exporter.cc @@ -544,7 +544,7 @@ void IFMapExporter::StateUpdateOnDequeue(IFMapUpdate *update, } if (update->advertise().empty()) { state->Remove(update); - if (state->update_list().empty() && state->IsInvalid()) { + if (state->CanDelete()) { assert(state->advertised().empty()); db_entry->ClearState(table, TableListenerId(table)); delete state; diff --git a/src/ifmap/ifmap_update.h b/src/ifmap/ifmap_update.h index 02ef713f780..1fc1c48855a 100644 --- a/src/ifmap/ifmap_update.h +++ b/src/ifmap/ifmap_update.h @@ -134,6 +134,7 @@ class IFMapState : public DBState { virtual bool IsInvalid() const { return sig_ == kInvalidSig; } const crc32type &crc() const { return crc_; } void SetCrc(crc32type &crc) { crc_ = crc; } + virtual bool CanDelete() = 0; protected: static const uint32_t kInvalidSig = -1; @@ -171,6 +172,9 @@ class IFMapNodeState : public IFMapState { const BitSet &nmask() const { return nmask_; } void nmask_clear() { nmask_.clear(); } void nmask_set(int bit) { nmask_.set(bit); } + virtual bool CanDelete() { + return (update_list().empty() && IsInvalid() && !HasDependents()); + } private: DEPENDENCY_LIST(IFMapLink, IFMapNodeState, dependents_); @@ -189,6 +193,9 @@ class IFMapLinkState : public IFMapState { IFMapNodeState *left() { return left_.get(); } IFMapNodeState *right() { return right_.get(); } + virtual bool CanDelete() { + return (update_list().empty() && IsInvalid()); + } private: DependencyRef left_;