only exit the dispatch loop if the node is closing

This commit is contained in:
StephenButtolph 2020-06-02 18:59:34 -04:00
parent 7671cab972
commit b8bd018938
3 changed files with 14 additions and 5 deletions

View File

@ -81,6 +81,7 @@ func main() {
defer node.Shutdown()
log.Debug("Dispatching node handlers")
node.Dispatch()
log.Debug("dispatching node handlers")
err = node.Dispatch()
log.Debug("dispatch returned with: %s", err)
}

View File

@ -485,7 +485,15 @@ func (n *network) Dispatch() error {
for {
conn, err := n.listener.Accept()
if err != nil {
return err
n.stateLock.Lock()
closed := n.closed
n.stateLock.Unlock()
if closed {
return err
}
n.log.Debug("error during server accept: %s", err)
continue
}
go n.upgrade(&peer{
net: n,

View File

@ -195,7 +195,7 @@ func (i *insecureValidatorManager) Disconnected(vdrID ids.ShortID) bool {
// Dispatch starts the node's servers.
// Returns when the node exits.
func (n *Node) Dispatch() {
func (n *Node) Dispatch() error {
// Add bootstrap nodes to the peer network
for _, peer := range n.Config.BootstrapPeers {
if !peer.IP.Equal(n.Config.StakingIP) {
@ -205,7 +205,7 @@ func (n *Node) Dispatch() {
}
}
n.Net.Dispatch()
return n.Net.Dispatch()
}
/*