From f29b90ff9cf37936bd8ef2c7ea5246cba8ec3b78 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Mon, 25 Jul 2022 16:03:02 +0200 Subject: [PATCH] fix for stats being checked after they are nil --- main.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 83c91e7..d60c326 100644 --- a/main.go +++ b/main.go @@ -125,6 +125,7 @@ func (m UploadManager) isBWInRange(bw float64) bool { } func (m UploadManager) pingWorker() error { +outerLoop: for { stats, err := doPing(conf.Host, conf.PPP, time.Second) if err != nil { @@ -141,19 +142,13 @@ func (m UploadManager) pingWorker() error { return err } - if stats == nil { - log.Warningf("ping to %s failed: %v", conf.Host, "no response") - time.Sleep(time.Duration(conf.Interval) * time.Minute) - continue - } - log.Infof("ping %s over threshold detected, starting extended pings...", stats.AvgRtt) for stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold { stats, err = doPing(conf.Host, conf.ConformationPPP, time.Second) if err != nil { log.Warningf("ping to %s failed: %v", conf.Host, err) time.Sleep(time.Duration(conf.Interval) * time.Minute) - continue + continue outerLoop } if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {