fix for stats being checked after they are nil

This commit is contained in:
2022-07-25 16:03:02 +02:00
parent 58f787e235
commit f29b90ff9c

View File

@@ -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 {