Skip to content

Commit bb341e9

Browse files
authored
[syncd] Bring back TimerWatchdog (sonic-net#821)
1 parent badf6ce commit bb341e9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

syncd/Syncd.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "RedisSelectableChannel.h"
1515
#include "ZeroMQSelectableChannel.h"
1616
#include "PerformanceIntervalTimer.h"
17+
#include "TimerWatchdog.h"
1718

1819
#include "sairediscommon.h"
1920

@@ -4295,6 +4296,14 @@ bool Syncd::isVeryFirstRun()
42954296
return firstRun;
42964297
}
42974298

4299+
static void timerWatchdogCallback(
4300+
_In_ int64_t span)
4301+
{
4302+
SWSS_LOG_ENTER();
4303+
4304+
SWSS_LOG_ERROR("main loop execution exceeded %ld us", span);
4305+
}
4306+
42984307
void Syncd::run()
42994308
{
43004309
SWSS_LOG_ENTER();
@@ -4342,6 +4351,10 @@ void Syncd::run()
43424351
runMainLoop = false;
43434352
}
43444353

4354+
TimerWatchdog twd(30 * 1000000); // watch for executions over 30 seconds
4355+
4356+
twd.setCallback(timerWatchdogCallback);
4357+
43454358
while(runMainLoop)
43464359
{
43474360
try
@@ -4350,6 +4363,8 @@ void Syncd::run()
43504363

43514364
int result = s->select(&sel);
43524365

4366+
twd.setStartTime();
4367+
43534368
if (sel == m_restartQuery.get())
43544369
{
43554370
/*
@@ -4438,6 +4453,8 @@ void Syncd::run()
44384453
{
44394454
SWSS_LOG_ERROR("select failed: %d", result);
44404455
}
4456+
4457+
twd.setEndTime();
44414458
}
44424459
catch(const std::exception &e)
44434460
{
@@ -4454,6 +4471,8 @@ void Syncd::run()
44544471

44554472
// make sure that if second exception will arise, then we break the loop
44564473
m_commandLineOptions->m_disableExitSleep = true;
4474+
4475+
twd.setEndTime();
44574476
}
44584477
}
44594478

0 commit comments

Comments
 (0)