closed check is now volatile

This commit is contained in:
Robinson 2023-08-09 21:28:03 -06:00
parent db385d0c1a
commit a7533d2c91
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
1 changed files with 9 additions and 4 deletions

View File

@ -119,8 +119,10 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
@Volatile
internal var criticalDriverError = false
@Volatile
private var closed = false
suspend fun closed(): Boolean = stateMutex.withLock {
fun closed(): Boolean {
return closed
}
@ -795,10 +797,13 @@ internal class AeronDriverInternal(endPoint: EndPoint<*>?, private val config: C
logger.trace { "Aeron Driver [$driverId]: Requested close... (${endPointUsages.size} endpoints still in use)" }
if (isInUse(logger)) {
logger.debug { "Aeron Driver [$driverId]: in use, not shutting down this instance." }
return@withLock false
// ignore the extra driver checks, because in SOME situations, when trying to reconnect upon an error, the
if (isInUse(endPoint, logger)) {
if (!criticalDriverError) {
// driver gets into a bad state. When this happens, we have to ignore "are we already in use" checks, BECAUSE the driver is now corrupted and unusable!
logger.debug { "Aeron Driver [$driverId]: in use, not shutting down this instance." }
return@withReentrantLock false
}
}
val removed = AeronDriver.driverConfigurations[driverId]