Skip to content

Commit

Permalink
swarm/network/stream: fix syncer ticker leak (ethereum#485)
Browse files Browse the repository at this point in the history
* swarm/network/stream: fix syncer ticker leak

* swarm/network/stream: a better ticker stop for syncer SetNextBatch
  • Loading branch information
janos authored and gbalint committed May 3, 2018
1 parent 9b724de commit d3e4e30
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions swarm/network/stream/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func (s *SwarmSyncerServer) SetNextBatch(from, to uint64) ([]byte, uint64, uint6
to = math.MaxUint64
}
var ticker *time.Ticker
defer func() {
if ticker != nil {
ticker.Stop()
}
}()
var wait bool
for {
if wait {
Expand All @@ -124,9 +129,6 @@ func (s *SwarmSyncerServer) SetNextBatch(from, to uint64) ([]byte, uint64, uint6
}
wait = true
}
if wait {
ticker.Stop()
}

log.Trace("Swarm syncer offer batch", "po", s.po, "len", i, "from", from, "to", to, "current store count", s.db.CurrentBucketStorageIndex(s.po))
return batch, from, to, nil, nil
Expand Down

0 comments on commit d3e4e30

Please sign in to comment.