mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
avoid multi Stop
This commit is contained in:
parent
aee0c4daff
commit
d9ba0016ad
1 changed files with 5 additions and 3 deletions
|
|
@ -119,10 +119,8 @@ func (s *Syncer) run() {
|
|||
retries++
|
||||
continue
|
||||
}
|
||||
// If the target number is smaller than the remote number, we don't need to sync.
|
||||
if target != nil && header.Number.Cmp(target.Number) <= 0 {
|
||||
log.Info("Syncer already synced", "hash", req.hash, "target", target)
|
||||
req.errc <- nil
|
||||
req.errc <- fmt.Errorf("stale sync target, current: %d, received: %d", target.Number, header.Number)
|
||||
break
|
||||
}
|
||||
target = header
|
||||
|
|
@ -162,7 +160,11 @@ func (s *Syncer) Start() error {
|
|||
// Stop terminates the synchronization service and stop all background activities.
|
||||
// This function can only be called for one time.
|
||||
func (s *Syncer) Stop() error {
|
||||
if s.closed == nil { // Already closed
|
||||
return nil
|
||||
}
|
||||
close(s.closed)
|
||||
s.closed = nil
|
||||
s.wg.Wait()
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue