forked from TrueCloudLab/neoneo-go
network: wait for the relayer thread to finish on shutdown
Unsubscribe and drain first, then return from the Shutdown method. It's important wrt to subsequent chain shutdown process (normally it's closed right after the network server).
This commit is contained in:
parent
155089f4e5
commit
dea75a4211
1 changed files with 4 additions and 0 deletions
|
@ -121,6 +121,7 @@ type (
|
||||||
register chan Peer
|
register chan Peer
|
||||||
unregister chan peerDrop
|
unregister chan peerDrop
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
|
relayFin chan struct{}
|
||||||
|
|
||||||
transactions chan *transaction.Transaction
|
transactions chan *transaction.Transaction
|
||||||
|
|
||||||
|
@ -170,6 +171,7 @@ func newServerFromConstructors(config ServerConfig, chain Ledger, stSync StateSy
|
||||||
id: randomID(),
|
id: randomID(),
|
||||||
config: chain.GetConfig(),
|
config: chain.GetConfig(),
|
||||||
quit: make(chan struct{}),
|
quit: make(chan struct{}),
|
||||||
|
relayFin: make(chan struct{}),
|
||||||
register: make(chan Peer),
|
register: make(chan Peer),
|
||||||
unregister: make(chan peerDrop),
|
unregister: make(chan peerDrop),
|
||||||
txInMap: make(map[util.Uint256]struct{}),
|
txInMap: make(map[util.Uint256]struct{}),
|
||||||
|
@ -273,6 +275,7 @@ func (s *Server) Shutdown() {
|
||||||
s.notaryRequestPool.StopSubscriptions()
|
s.notaryRequestPool.StopSubscriptions()
|
||||||
}
|
}
|
||||||
close(s.quit)
|
close(s.quit)
|
||||||
|
<-s.relayFin
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddService allows to add a service to be started/stopped by Server.
|
// AddService allows to add a service to be started/stopped by Server.
|
||||||
|
@ -1433,6 +1436,7 @@ drainBlocksLoop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(ch)
|
close(ch)
|
||||||
|
close(s.relayFin)
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifyAndPoolTX verifies the TX and adds it to the local mempool.
|
// verifyAndPoolTX verifies the TX and adds it to the local mempool.
|
||||||
|
|
Loading…
Reference in a new issue