fix for stats being checked after they are nil
This commit is contained in:
9
main.go
9
main.go
@@ -125,6 +125,7 @@ func (m UploadManager) isBWInRange(bw float64) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m UploadManager) pingWorker() error {
|
func (m UploadManager) pingWorker() error {
|
||||||
|
outerLoop:
|
||||||
for {
|
for {
|
||||||
stats, err := doPing(conf.Host, conf.PPP, time.Second)
|
stats, err := doPing(conf.Host, conf.PPP, time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -141,19 +142,13 @@ func (m UploadManager) pingWorker() error {
|
|||||||
return err
|
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)
|
log.Infof("ping %s over threshold detected, starting extended pings...", stats.AvgRtt)
|
||||||
for stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {
|
for stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {
|
||||||
stats, err = doPing(conf.Host, conf.ConformationPPP, time.Second)
|
stats, err = doPing(conf.Host, conf.ConformationPPP, time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("ping to %s failed: %v", conf.Host, err)
|
log.Warningf("ping to %s failed: %v", conf.Host, err)
|
||||||
time.Sleep(time.Duration(conf.Interval) * time.Minute)
|
time.Sleep(time.Duration(conf.Interval) * time.Minute)
|
||||||
continue
|
continue outerLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {
|
if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {
|
||||||
|
Reference in New Issue
Block a user