From b4c7203c71510d94cae09b4c3deb3a49ebd7a01f Mon Sep 17 00:00:00 2001 From: Robinson Date: Wed, 1 Mar 2023 12:49:10 +0100 Subject: [PATCH] Close the network Event dispatcher when done --- src/dorkbox/network/connection/EndPoint.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dorkbox/network/connection/EndPoint.kt b/src/dorkbox/network/connection/EndPoint.kt index 765e3000..94b51522 100644 --- a/src/dorkbox/network/connection/EndPoint.kt +++ b/src/dorkbox/network/connection/EndPoint.kt @@ -1039,10 +1039,15 @@ internal constructor(val type: Class<*>, close0() aeronDriver.close() + // This closes the scope and all children in the scope eventDispatch.cancel("${type.simpleName} shutting down") messageDispatch.cancel("${type.simpleName} shutting down") + // this will ONLY close the event dispatcher if ALL endpoints have closed it. + // when an endpoint closes, the poll-loop shuts down, and removes itself from the list of poll actions that need to be performed. + networkEventDispatcher.close() + shutdownLatch = CountDownLatch(1) // if we are waiting for shutdown, cancel the waiting thread (since we have shutdown now)