Skip to content

Commit

Permalink
Merge "Prevent instance/table from getting deleted while iterating"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Aug 14, 2015
2 parents f60f8bd + 40a2a9c commit 4e408f7
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/bgp/test/bgp_show_route_summary_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ class BgpShowRouteSummaryTest : public ::testing::Test {
}
}

void PauseTableDeletion() {
void PauseResumeTableDeletion(bool pause) {
task_util::TaskSchedulerLock lock;
RoutingInstanceMgr *rim = server_->routing_instance_mgr();
for (RoutingInstanceMgr::name_iterator it1 = rim->name_begin();
it1 != rim->name_end(); ++it1) {
Expand All @@ -154,23 +155,21 @@ class BgpShowRouteSummaryTest : public ::testing::Test {
rtinstance->GetTables().begin();
it2 != rtinstance->GetTables().end(); ++it2) {
BgpTable *table = it2->second;
table->deleter()->PauseDelete();
if (pause) {
table->deleter()->PauseDelete();
} else {
table->deleter()->ResumeDelete();
}
}
}
}

void PauseTableDeletion() {
PauseResumeTableDeletion(true);
}

void ResumeTableDeletion() {
RoutingInstanceMgr *rim = server_->routing_instance_mgr();
for (RoutingInstanceMgr::name_iterator it1 = rim->name_begin();
it1 != rim->name_end(); ++it1) {
RoutingInstance *rtinstance = it1->second;
for (RoutingInstance::RouteTableList::iterator it2 =
rtinstance->GetTables().begin();
it2 != rtinstance->GetTables().end(); ++it2) {
BgpTable *table = it2->second;
table->deleter()->ResumeDelete();
}
}
PauseResumeTableDeletion(false);
}

EventManager evm_;
Expand Down

0 comments on commit 4e408f7

Please sign in to comment.