Only start bandwidth ticker when necessary.

- Only start the token ticker when the timetable entry has more than one
  entry.
- This fixes the "Scheduled bandwidth change" log message when no
  bwlimit is specified.
- Fixes #987
This commit is contained in:
Marco Paganini 2017-01-04 19:03:49 -08:00
parent e1a49ca426
commit 6611d92e21

View File

@ -43,6 +43,12 @@ func startTokenBucket() {
// startTokenTicker creates a ticker to update the bandwidth limiter every minute.
func startTokenTicker() {
// If the timetable has a single entry or was not specified, we don't need
// a ticker to update the bandwidth.
if len(bwLimit) <= 1 {
return
}
ticker := time.NewTicker(time.Minute)
go func() {
for range ticker.C {