Skip to content

Commit

Permalink
added fucntion def for stopping natstatsmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhavanaashok33 committed Oct 2, 2023
1 parent 171e607 commit 1f0a40a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion agent-ovs/ovs/NatStatsManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
/*
* Include file for stats manager
*
Expand Down Expand Up @@ -61,6 +60,25 @@ void NatStatsManager::start() {
timer->async_wait(bind(&NatStatsManager::on_timer, this, error));
}

void NatStatsManager::stop() {
stopping = true;

LOG(DEBUG) << "Stopping Nat stats manager " << this;
if (connection) {
connection->UnregisterMessageHandler(OFPTYPE_FLOW_STATS_REPLY, this);
connection->UnregisterMessageHandler(OFPTYPE_FLOW_REMOVED, this);
}
try {
std::lock_guard<std::mutex> guard(timer_mutex);
if (timer) {
LOG(DEBUG) << "timer cancelled";
timer->cancel();
}
} catch (const boost::system::system_error &e ) {
LOG(DEBUG) << "Failed to cancel timer: " << e.what();
}
}

void NatStatsManager::on_timer(const error_code& ec) {
if (ec) {
std::lock_guard<std::mutex> lock(timer_mutex);
Expand Down

0 comments on commit 1f0a40a

Please sign in to comment.