agent: Prevent hot spin on event list

This commit is contained in:
Armon Dadgar 2014-08-28 15:55:36 -07:00
parent 3b01d24376
commit d9ae1da296
1 changed files with 4 additions and 1 deletions

View File

@ -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)