My recent PR#325 contained a couple of mistakes. In particular on Unix, but not windows the shutdown hook unregister can give a non-fatal exception during some tests. Also, I got the point of client messaging service stop registration wrong, which was leading to the server shutting down teh client session ahead of the proper stop sequence.

This commit is contained in:
Matthew Nesbit 2016-09-06 14:47:42 +01:00
parent 63e2ec32cf
commit 58aa933307
2 changed files with 2 additions and 2 deletions

View File

@ -168,7 +168,6 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
checkpointStorage = storageServices.second
netMapCache = InMemoryNetworkMapCache()
net = makeMessagingService()
runOnStop += Runnable { net.stop() }
wallet = makeWalletService()
identity = makeIdentityService()
@ -211,6 +210,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
ScheduledActivityObserver(services)
startMessagingService()
runOnStop += Runnable { net.stop() }
_networkMapRegistrationFuture.setFuture(registerWithNetworkMap())
isPreviousCheckpointsPresent = checkpointStorage.checkpoints.any()
smm.start()

View File

@ -281,7 +281,7 @@ class Node(dir: Path, val p2pAddr: HostAndPort, val webServerAddr: HostAndPort,
shutdown = true
// Unregister shutdown hook to prevent any unnecessary second calls to stop
if(shutdownThread != null) {
if((shutdownThread != null) && (Thread.currentThread() != shutdownThread)){
Runtime.getRuntime().removeShutdownHook(shutdownThread)
shutdownThread = null
}