From a5e78e3814a55cb3659e49b634febb36f01a9423 Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Thu, 19 Oct 2017 21:55:42 -0700 Subject: [PATCH] Fix validator bugs --- ops/validator.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ops/validator.go b/ops/validator.go index 03371ba..4e443cf 100644 --- a/ops/validator.go +++ b/ops/validator.go @@ -19,17 +19,15 @@ type Validator struct { Logger tacitus.Logger Products []string - done chan struct{} - dirty bool + done chan struct{} + stopped bool + dirty bool } func (v *Validator) Stop() { - if v.done != nil { - select { - case v.done <- struct{}{}: - default: - } - + if v.done != nil && !v.stopped { + v.done <- struct{}{} + v.stopped = true } } @@ -52,6 +50,7 @@ func (v *Validator) Start(frequency time.Duration) { for !done { select { case <-v.done: + v.Logger.Info("Done") done = true ticker.Stop() case <-ticker.C: @@ -81,7 +80,6 @@ func (v *Validator) emitProducts(done chan struct{}) { } }() - } func (v *Validator) validateProduct(product string) {