Skip to content

Commit 0c46242

Browse files
authored
[orchagent] Flush pipeline every 1 second, not only when select will timeout (sonic-net#2003)
* Added flush for async communication pipeline, every 1 second, not only if select will timeout.
1 parent 339101c commit 0c46242

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

orchagent/orchdaemon.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <unistd.h>
22
#include <unordered_map>
3+
#include <chrono>
34
#include <limits.h>
45
#include "orchdaemon.h"
56
#include "logger.h"
@@ -645,13 +646,26 @@ void OrchDaemon::start()
645646
m_select->addSelectables(o->getSelectables());
646647
}
647648

649+
auto tstart = std::chrono::high_resolution_clock::now();
650+
648651
while (true)
649652
{
650653
Selectable *s;
651654
int ret;
652655

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

658+
auto tend = std::chrono::high_resolution_clock::now();
659+
660+
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(tend - tstart);
661+
662+
if (diff.count() >= SELECT_TIMEOUT)
663+
{
664+
tstart = std::chrono::high_resolution_clock::now();
665+
666+
flush();
667+
}
668+
655669
if (ret == Select::ERROR)
656670
{
657671
SWSS_LOG_NOTICE("Error: %s!\n", strerror(errno));

0 commit comments

Comments
 (0)