From f0bc1b6cd05442e29f8e6bd43e2402d50d90b051 Mon Sep 17 00:00:00 2001 From: gmarek Date: Mon, 15 Feb 2016 15:11:38 +0100 Subject: [PATCH] Fix log gatherer --- test/e2e/log_size_monitoring.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/e2e/log_size_monitoring.go b/test/e2e/log_size_monitoring.go index 5f1eef7663a..30de88d2b4b 100644 --- a/test/e2e/log_size_monitoring.go +++ b/test/e2e/log_size_monitoring.go @@ -218,6 +218,15 @@ func (g *LogSizeGatherer) Run() { } } +func (g *LogSizeGatherer) pushWorkItem(workItem WorkItem) { + select { + case <-time.After(time.Duration(workItem.backoffMultiplier) * pollingPeriod): + g.workChannel <- workItem + case <-g.stopChannel: + return + } +} + // Work does a single unit of work: tries to take out a WorkItem from the queue, ssh-es into a given machine, // gathers data, writes it to the shared map, and creates a gorouting which reinserts work item into // the queue with a delay. Returns false if worker should exit. @@ -239,7 +248,7 @@ func (g *LogSizeGatherer) Work() bool { if workItem.backoffMultiplier < 128 { workItem.backoffMultiplier *= 2 } - g.workChannel <- workItem + go g.pushWorkItem(workItem) return true } workItem.backoffMultiplier = 1 @@ -255,13 +264,6 @@ func (g *LogSizeGatherer) Work() bool { } g.data.AddNewData(workItem.ip, path, now, size) } - go func() { - select { - case <-time.After(time.Duration(workItem.backoffMultiplier) * pollingPeriod): - g.workChannel <- workItem - case <-g.stopChannel: - return - } - }() + go g.pushWorkItem(workItem) return true }