From d9ae1da2964627b8e363de97ef40388cb9125773 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 28 Aug 2014 15:55:36 -0700 Subject: [PATCH] agent: Prevent hot spin on event list --- command/agent/event_endpoint.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/command/agent/event_endpoint.go b/command/agent/event_endpoint.go index 875297b2f..bd3e90f6e 100644 --- a/command/agent/event_endpoint.go +++ b/command/agent/event_endpoint.go @@ -133,7 +133,10 @@ RUN_QUERY: // Determine the index var index uint64 if len(events) == 0 { - index = 0 + // Return a non-zero index to prevent a hot query loop. This + // can be caused by a watch for example when there is no matching + // events. + index = 1 } else { last := events[len(events)-1] index = uuidToUint64(last.ID)