rapid decreasing of upload if necessary
This commit is contained in:
13
main.go
13
main.go
@@ -121,9 +121,8 @@ func (m UploadManager) pingWorker() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.isBWInRange(up - conf.Bandwidth.Step) {
|
||||
log.Infof("Ping over threshold (%s) detected, confirming...", stats.AvgRtt)
|
||||
|
||||
log.Infof("Ping %s over threshold detected, starting extensive pinging...", stats.AvgRtt)
|
||||
for stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold && m.isBWInRange(up-conf.Bandwidth.Step) {
|
||||
stats, err = doPing(conf.Host, conf.ConformationPPP, time.Second)
|
||||
if err != nil {
|
||||
log.Warningf("ping to %s failed: %v", conf.Host, err)
|
||||
@@ -132,16 +131,14 @@ func (m UploadManager) pingWorker() error {
|
||||
}
|
||||
|
||||
if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {
|
||||
log.Infof("Ping confirmed (%s), adjusting upload TC %d->%d", stats.AvgRtt, up, up-conf.Bandwidth.Step)
|
||||
log.Infof("extended ping %s, adjusting upload TC %d->%d", stats.AvgRtt, up, up-conf.Bandwidth.Step)
|
||||
err = m.SetUpload(up - conf.Bandwidth.Step)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
m.LastOver = time.Now()
|
||||
}
|
||||
} else {
|
||||
log.Infof("Ping over threshold (%s) detected, but no bandwidth available", stats.AvgRtt)
|
||||
m.LastOver = time.Now()
|
||||
time.Sleep(20 * time.Second)
|
||||
}
|
||||
} else if time.Since(m.LastOver) >= time.Duration(conf.TryRestoringAfter)*time.Minute {
|
||||
up, err := m.Upload()
|
||||
@@ -149,7 +146,7 @@ func (m UploadManager) pingWorker() error {
|
||||
return err
|
||||
}
|
||||
if m.isBWInRange(up + conf.Bandwidth.Step) {
|
||||
log.Infof("trying to increase upload TC %d->%d", up, up+conf.Bandwidth.Step)
|
||||
log.Infof("Short ping %s, trying to increase upload TC %d->%d", stats.AvgRtt, up, up+conf.Bandwidth.Step)
|
||||
err = m.SetUpload(up + conf.Bandwidth.Step)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user