Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Sun <[email protected]>
  • Loading branch information
stephenxs committed Jan 2, 2025
1 parent 0e4b4b4 commit 608b1f2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,11 @@ void SwitchOrch::onSwitchAsicSdkHealthEvent(sai_object_id_t switch_id,
const double year_in_seconds = 86400 * 365;
stringstream time_ss;

/*
* In case vendor SAI passed a very large timestamp, put_time can cause segment fault which can not be caught by try/catch infra
* We check the difference between the timestamp from SAI and the current time and force to use current time if the gap is too large
* By doing so, we can avoid the segment fault
*/
if (difftime(t, now) > year_in_seconds)
{
SWSS_LOG_ERROR("Invalid timestamp second %" PRIx64 " in received ASIC/SDK health event, reset to current time", timestamp.tv_sec);
Expand Down

0 comments on commit 608b1f2

Please sign in to comment.