mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56: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()
|
n.lock.Lock()
|
||||||
defer n.lock.Unlock()
|
defer n.lock.Unlock()
|
||||||
|
|
||||||
// Short circuit if the node's not running
|
|
||||||
if n.server == nil {
|
if n.server == nil {
|
||||||
return ErrNodeStopped
|
return ErrNodeStopped
|
||||||
}
|
}
|
||||||
// Otherwise terminate all the services and the P2P server too
|
|
||||||
failure := &StopError{
|
// Stop the server first. This will block until all connections
|
||||||
Services: make(map[reflect.Type]error),
|
// are done interacting.
|
||||||
}
|
n.server.Stop()
|
||||||
|
// Stop all services.
|
||||||
|
failure := &StopError{Services: make(map[reflect.Type]error)}
|
||||||
for kind, service := range n.services {
|
for kind, service := range n.services {
|
||||||
if err := service.Stop(); err != nil {
|
if err := service.Stop(); err != nil {
|
||||||
failure.Services[kind] = err
|
failure.Services[kind] = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n.server.Stop()
|
|
||||||
|
|
||||||
n.services = nil
|
n.services = nil
|
||||||
n.server = nil
|
n.server = nil
|
||||||
close(n.stop)
|
close(n.stop)
|
||||||
|
|
||||||
if len(failure.Services) > 0 {
|
if len(failure.Services) > 0 {
|
||||||
return failure
|
return failure
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue