From 444010ea3c3183af00f9726795a446481949c5c2 Mon Sep 17 00:00:00 2001 From: Tapan Karwa Date: Wed, 29 Apr 2015 16:13:59 -0700 Subject: [PATCH] Fix for assert in IFMapExporter::StateUpdateOnDequeue The following sequences causes the problem. Fixing it: The sequence is: 1. Exporter gets an add or change. Exporter processes it and adds it to the queue as an 'update'. 2. The queue 'update' has not been processed yet and exporter gets a delete for the node. 3. The queue 'update' (not 'delete') is processed leading to the assert being true. Change-Id: I38b6d1dbedaaafe8d631276d5c97b1485e6a2f42 Closes-Bug: 1430091 --- src/ifmap/ifmap_exporter.cc | 2 +- src/ifmap/ifmap_update.h | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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_;