LCOV - code coverage report
Current view: top level - vnsw/agent/port_ipc - config_stale_cleaner.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 13 33 39.4 %
Date: 2026-11-09 02:10:49 Functions: 5 9 55.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include <cfg/cfg_init.h>
       7             : #include <cfg/cfg_types.h>
       8             : #include <port_ipc/port_ipc_types.h>
       9             : #include "config_stale_cleaner.h"
      10             : #include "port_ipc_handler.h"
      11             : #include "port_subscribe_table.h"
      12             : 
      13           2 : ConfigStaleCleaner::ConfigStaleCleaner(Agent *agent, TimerCallback callback) :
      14           2 :     agent_(agent),
      15           2 :     timeout_(kConfigStaleTimeout), audit_callback_(callback) {
      16           2 : }
      17             : 
      18           2 : ConfigStaleCleaner::~ConfigStaleCleaner() {
      19             :     // clean up the running timers
      20           2 :     for (std::set<Timer *>::iterator it = running_timer_list_.begin();
      21           2 :          it != running_timer_list_.end(); ++it) {
      22           0 :         TimerManager::DeleteTimer(*it);
      23             :     }
      24           2 : }
      25             : 
      26           0 : void ConfigStaleCleaner::StartStaleCleanTimer(int32_t version) {
      27             :     // create timer, to be deleted on completion
      28             :     Timer *timer =
      29           0 :         TimerManager::CreateTimer(
      30           0 :             *(agent_->event_manager())->io_service(), "Stale cleanup timer",
      31           0 :             TaskScheduler::GetInstance()->GetTaskId("db::DBTable"), 0, true);
      32           0 :     running_timer_list_.insert(timer);
      33           0 :     timer->Start(timeout_,
      34             :                  boost::bind(&ConfigStaleCleaner::StaleEntryTimeout, this,
      35             :                              version, timer));
      36           0 : }
      37             : 
      38           0 : bool ConfigStaleCleaner::StaleEntryTimeout(int32_t version, Timer *timer) {
      39           0 :     if (!audit_callback_.empty()) {
      40           0 :         audit_callback_(version);
      41             :     }
      42           0 :     running_timer_list_.erase(timer);
      43           0 :     return false;
      44             : }
      45             : 
      46             : ////////////////////////////////////////////////////////////////////////////////
      47             : 
      48           2 : InterfaceConfigStaleCleaner::InterfaceConfigStaleCleaner(Agent *agent) :
      49           2 :     ConfigStaleCleaner(agent, NULL) {
      50           2 : }
      51             : 
      52           4 : InterfaceConfigStaleCleaner::~InterfaceConfigStaleCleaner() {
      53           4 : }
      54             : 
      55             : bool
      56           0 : InterfaceConfigStaleCleaner::OnInterfaceConfigStaleTimeout(int32_t version) {
      57             :     PortSubscribeTable *table =
      58           0 :         agent_->port_ipc_handler()->port_subscribe_table();
      59           0 :     if (!table) {
      60           0 :         return false;
      61             :     }
      62             : 
      63           0 :     CONFIG_TRACE(PortInfo, "InterfaceConfigStaleCleaner Walk invoked.");
      64           0 :     table->StaleWalk(version);
      65           0 :     return false;
      66             : }

Generated by: LCOV version 1.14