close the sub/pub for a client when it fails to connect (prevent disk space leak)

This commit is contained in:
Robinson 2022-12-15 23:57:22 +01:00
parent a7e520caed
commit ad4073c632
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
2 changed files with 8 additions and 5 deletions

View File

@ -496,11 +496,6 @@ open class Client<CONNECTION : Connection>(
connect0(handshake, handshakeConnection, handshakeTimeoutSec) connect0(handshake, handshakeConnection, handshakeTimeoutSec)
success = true success = true
// finished with the handshake, so always close the connection publication
// The subscription is RE-USED, so we don't close that!
handshakeConnection.publication.close()
// once we're done with the connection process, stop trying // once we're done with the connection process, stop trying
break break
} catch (e: ClientRetryException) { } catch (e: ClientRetryException) {
@ -754,6 +749,10 @@ open class Client<CONNECTION : Connection>(
throw e throw e
} }
// finished with the handshake, so always close the connection publication
// The subscription is RE-USED, so we don't close that!
handshakeConnection.publication.close()
isConnected = true isConnected = true
logger.debug { "[$aeronLogInfo - ${handshake.connectKey}] Connection (${newConnection.id}) to $remoteAddressString done with handshake." } logger.debug { "[$aeronLogInfo - ${handshake.connectKey}] Connection (${newConnection.id}) to $remoteAddressString done with handshake." }

View File

@ -276,6 +276,10 @@ internal class ClientHandshake<CONNECTION: Connection>(
} }
if (!connectionDone) { if (!connectionDone) {
// since this failed, close everything
handshakeConnection.subscription.close()
handshakeConnection.publication.close()
val exception = ClientTimedOutException("Waiting for registration response from server") val exception = ClientTimedOutException("Waiting for registration response from server")
ListenerManager.cleanStackTraceInternal(exception) ListenerManager.cleanStackTraceInternal(exception)
throw exception throw exception