Skip to content

Commit

Permalink
[counter] Clear counter table when init
Browse files Browse the repository at this point in the history
  • Loading branch information
yaqiangz committed Dec 19, 2023
1 parent 40c6877 commit f1a5f79
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,15 @@ void prepare_socket_callback(event_base *base, int socket, void (*cb)(evutil_soc
event_add(event, NULL);
}

void clear_counter(std::shared_ptr<swss::DBConnector> statdb) {
std::string match_pattern = counter_table + std::string("*");
auto keys = statdb->keys(match_pattern);

for (auto &itr : keys) {
statdb.del(itr);
}
}

/**
* @code loop_relay(std::unordered_map<relay_config> &vlans);
*
Expand Down Expand Up @@ -1513,6 +1522,8 @@ void loop_relay(std::unordered_map<std::string, relay_config> &vlans) {
prepare_socket_callback(base, out_filter, outbound_callback, reinterpret_cast<void *>(state_db.get()));
sockets.push_back(out_filter);

clear_counter(state_db);

int lo_sock = -1;
if (dual_tor_sock) {
std::string lo_string(loopback);
Expand Down

0 comments on commit f1a5f79

Please sign in to comment.