mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
Merge d2a437ecac into 3274db19c7
This commit is contained in:
commit
b574b0a127
1 changed files with 6 additions and 8 deletions
14
node/node.go
14
node/node.go
|
|
@ -178,25 +178,23 @@ func (n *Node) Stop() error {
|
|||
n.lock.Lock()
|
||||
defer n.lock.Unlock()
|
||||
|
||||
// Short circuit if the node's not running
|
||||
if n.server == nil {
|
||||
return ErrNodeStopped
|
||||
}
|
||||
// Otherwise terminate all the services and the P2P server too
|
||||
failure := &StopError{
|
||||
Services: make(map[reflect.Type]error),
|
||||
}
|
||||
|
||||
// Stop the server first. This will block until all connections
|
||||
// are done interacting.
|
||||
n.server.Stop()
|
||||
// Stop all services.
|
||||
failure := &StopError{Services: make(map[reflect.Type]error)}
|
||||
for kind, service := range n.services {
|
||||
if err := service.Stop(); err != nil {
|
||||
failure.Services[kind] = err
|
||||
}
|
||||
}
|
||||
n.server.Stop()
|
||||
|
||||
n.services = nil
|
||||
n.server = nil
|
||||
close(n.stop)
|
||||
|
||||
if len(failure.Services) > 0 {
|
||||
return failure
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue