From 2571ea61bbaacfda71fb6b8ac212b8b7f58ffd26 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Thu, 26 May 2016 18:23:44 -0700 Subject: [PATCH] Initializing the ring buffer with no cells --- client/task_runner.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/task_runner.go b/client/task_runner.go index 7ee22f8dc..63d3a7689 100644 --- a/client/task_runner.go +++ b/client/task_runner.go @@ -461,8 +461,11 @@ func (r *TaskRunner) startTask() error { // collectResourceUsageStats starts collecting resource usage stats of a Task func (r *TaskRunner) collectResourceUsageStats() { + // start collecting the stats right away and then start collecting every + // collection interval + next := time.NewTimer(0) + defer next.Stop() for { - next := time.NewTimer(r.config.StatsCollectionInterval) select { case <-next.C: ru, err := r.handle.Stats() @@ -474,7 +477,6 @@ func (r *TaskRunner) collectResourceUsageStats() { r.resourceUsageLock.Unlock() next.Reset(r.config.StatsCollectionInterval) case <-r.handle.WaitCh(): - next.Stop() return } }