From 248822a3d6ae8240c2ba01925484e3ea4227b1f4 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 14 Oct 2016 11:41:53 +0100 Subject: [PATCH] Fix #86 - set a 20s min threshold before re-polling --- .../matrix-org/go-neb/services/rssbot/rssbot.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go index 021e860..226d83a 100644 --- a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go +++ b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go @@ -158,6 +158,14 @@ func (s *rssBotService) nextTimestamp() time.Time { earliestNextTs = feedInfo.NextPollTimestampSecs } } + + // Don't allow times in the past. Set a min re-poll threshold of 20s to avoid + // tight-looping on feeds which 500. + now := time.Now().Unix() + if earliestNextTs <= now { + earliestNextTs = now + 20 + } + return time.Unix(earliestNextTs, 0) }