Skip to content

Commit

Permalink
[orchagent] Flush pipeline every 1 second, not only when select will …
Browse files Browse the repository at this point in the history
…timeout (sonic-net#2003)

* Added flush for async communication pipeline, every 1 second, not only if select will timeout.
  • Loading branch information
kcudnik authored Nov 16, 2021
1 parent 339101c commit 0c46242
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <unordered_map>
#include <chrono>
#include <limits.h>
#include "orchdaemon.h"
#include "logger.h"
Expand Down Expand Up @@ -645,13 +646,26 @@ void OrchDaemon::start()
m_select->addSelectables(o->getSelectables());
}

auto tstart = std::chrono::high_resolution_clock::now();

while (true)
{
Selectable *s;
int ret;

ret = m_select->select(&s, SELECT_TIMEOUT);

auto tend = std::chrono::high_resolution_clock::now();

auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(tend - tstart);

if (diff.count() >= SELECT_TIMEOUT)
{
tstart = std::chrono::high_resolution_clock::now();

flush();
}

if (ret == Select::ERROR)
{
SWSS_LOG_NOTICE("Error: %s!\n", strerror(errno));
Expand Down

0 comments on commit 0c46242

Please sign in to comment.