From 63547f2d3785bdcca23aa2b0a640eb30b3531786 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Mon, 3 Mar 2014 22:59:50 -0800 Subject: [PATCH] Forgot to close some chans --- bandwidth.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bandwidth.go b/bandwidth.go index 39c9f1b..15e0083 100644 --- a/bandwidth.go +++ b/bandwidth.go @@ -73,6 +73,8 @@ outer: } close(bw.AddRx) close(bw.AddTx) + close(bw.Rx) + close(bw.Tx) } // datum stores both a piece of info, plus the time at which that info was @@ -116,6 +118,16 @@ func newStream(seconds []int) *stream { func (s *stream) add(v datum) { s.data.PushBack(v) +} + +func (s *stream) averages() []float64 { + var limit time.Time + total := 0.0 + totals := []float64{} + + if s.data.Back() == nil { + return totals + } newest := s.data.Back().Value.(datum) cutoff := newest.at.Add(s.max) for e := s.data.Front(); e != nil; e = e.Next() { @@ -126,19 +138,7 @@ func (s *stream) add(v datum) { break } } -} -func (s *stream) averages() []float64 { - var limit time.Time - - total := 0.0 - - totals := []float64{} - if s.data.Back() == nil { - return totals - } - - newest := s.data.Back().Value.(datum) e := s.data.Back() for _, extent := range s.extents {