Safer closing of the aeron client during close process

This commit is contained in:
nathan 2020-09-23 16:59:58 +02:00
parent 9bac797541
commit 8605040819

View File

@ -648,12 +648,14 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A
if (shutdown.compareAndSet(expect = false, update = true)) {
logger.info { "Shutting down..." }
aeron.close()
(aeron.context().threadFactory() as NamedThreadFactory).group.destroy()
try {
aeron.close()
} catch (e: Exception) {
logger.error("Error stopping aeron.", e)
}
runBlocking {
AeronConfig.stopDriver(mediaDriver, logger)
connections.forEach {
it.close()
}
@ -668,6 +670,8 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A
close0()
(aeron.context().threadFactory() as NamedThreadFactory).group.destroy()
// if we are waiting for shutdown, cancel the waiting thread (since we have shutdown now)
shutdownWaiter.cancel()
}