Skip to content

Commit

Permalink
Add life time references to all referred tables from service chain
Browse files Browse the repository at this point in the history
Also Shutdown the work queue before deletion

Closes-Bug: #1594987
Change-Id: I1ce17ccb8c62fa6d2ce0920a1ddabdd289ad6744
  • Loading branch information
ananth-at-camphor-networks committed Jun 21, 2016
1 parent fa977c3 commit 2a6ca3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/bgp/routing-instance/service_chaining.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ ServiceChain<T>::ServiceChain(ServiceChainMgrT *manager, RoutingInstance *src,
connected_table_unregistered_(false),
dest_table_unregistered_(false),
aggregate_(false),
src_table_delete_ref_(this, src_table()->deleter()) {
src_table_delete_ref_(this, src_table()->deleter()),
dest_table_delete_ref_(this, dest_table()->deleter()),
connected_table_delete_ref_(this, connected_table()->deleter()) {
for (vector<string>::const_iterator it = subnets.begin();
it != subnets.end(); ++it) {
error_code ec;
Expand Down Expand Up @@ -904,9 +906,9 @@ ServiceChainMgr<T>::ServiceChainMgr(BgpServer *server)
service_chain_task_id_ = scheduler->GetTaskId("bgp::ServiceChain");
}

process_queue_ =
process_queue_.reset(
new WorkQueue<ServiceChainRequestT *>(service_chain_task_id_, 0,
bind(&ServiceChainMgr::RequestHandler, this, _1));
bind(&ServiceChainMgr::RequestHandler, this, _1)));

id_ = server->routing_instance_mgr()->RegisterInstanceOpCallback(
bind(&ServiceChainMgr::RoutingInstanceCallback, this, _1, _2));
Expand All @@ -918,7 +920,7 @@ ServiceChainMgr<T>::ServiceChainMgr(BgpServer *server)

template <typename T>
ServiceChainMgr<T>::~ServiceChainMgr() {
delete process_queue_;
process_queue_->Shutdown();
server_->routing_instance_mgr()->UnregisterInstanceOpCallback(id_);
BgpMembershipManager *membership_mgr = server_->membership_mgr();
membership_mgr->UnregisterPeerRegistrationCallback(registration_id_);
Expand Down
4 changes: 3 additions & 1 deletion src/bgp/routing-instance/service_chaining.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ class ServiceChain : public ConditionMatch {
bool dest_table_unregistered_;
bool aggregate_; // Whether the host route needs to be aggregated
LifetimeRef<ServiceChain> src_table_delete_ref_;
LifetimeRef<ServiceChain> dest_table_delete_ref_;
LifetimeRef<ServiceChain> connected_table_delete_ref_;

// Helper function to match
bool IsMoreSpecific(BgpRoute *route, PrefixT *aggregate_match) const;
Expand Down Expand Up @@ -309,7 +311,7 @@ class ServiceChainMgr : public IServiceChainMgr {
BgpServer *server_;
BgpConditionListener *listener_;
boost::scoped_ptr<TaskTrigger> resolve_trigger_;
WorkQueue<ServiceChainRequestT *> *process_queue_;
boost::scoped_ptr<WorkQueue<ServiceChainRequestT *> > process_queue_;
bool aggregate_host_route_;
ServiceChainMap chain_set_;
PendingServiceChainList pending_chains_;
Expand Down

0 comments on commit 2a6ca3c

Please sign in to comment.