inUse check now uses the endpoint for extra checks

This commit is contained in:
Robinson 2023-08-09 21:23:52 -06:00
parent 28d170c25c
commit db385d0c1a
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
2 changed files with 5 additions and 5 deletions

View File

@ -164,7 +164,7 @@ class AeronDriver private constructor(config: Configuration, val logger: KLogger
driverConfigurations.forEach { entry ->
val driver = entry.value
val closed = if (traceEnabled) driver.isInUse(logger) else driver.isRunning()
val closed = if (traceEnabled) driver.isInUse(null, logger) else driver.isRunning()
if (closed) {
logger.error { "Aeron Driver [${driver.driverId}]: still running during check (${driver.aeronDirectory})" }
@ -176,7 +176,7 @@ class AeronDriver private constructor(config: Configuration, val logger: KLogger
// this is already checked if we are in trace mode.
driverConfigurations.forEach { entry ->
val driver = entry.value
if (driver.isInUse(logger)) {
if (driver.isInUse(null, logger)) {
logger.error { "Aeron Driver [${driver.driverId}]: still in use during check (${driver.aeronDirectory})" }
return@withLock false
}

View File

@ -710,14 +710,13 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
return context.isRunning()
}
suspend fun isInUse(logger: KLogger): Boolean {
suspend fun isInUse(endPoint: EndPoint<*>?, logger: KLogger): Boolean {
// as many "sort-cuts" as we can for checking if the current Aeron Driver/client is still in use
if (!isRunning()) {
logger.trace { "Aeron Driver [$driverId]: not running" }
return false
}
val driverId = config.id
if (registeredPublications.value > 0) {
if (logger.isTraceEnabled) {
val elements = registeredPublicationsTrace.elements
@ -740,7 +739,7 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
return true
}
if (endPointUsages.isNotEmpty()) {
if (endPointUsages.size > 1 && !endPointUsages.contains(endPoint)) {
logger.debug { "Aeron Driver [$driverId]: still referenced by ${endPointUsages.size} endpoints" }
return true
}
@ -799,6 +798,7 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
if (isInUse(logger)) {
logger.debug { "Aeron Driver [$driverId]: in use, not shutting down this instance." }
return@withLock false
if (isInUse(endPoint, logger)) {
}
val removed = AeronDriver.driverConfigurations[driverId]