When creating publications and handshaking, we CANNOT do this on the main processing thread
This commit is contained in:
parent
af19049519
commit
a5286899b7
|
@ -223,6 +223,8 @@ internal class ServerHandshake<CONNECTION : Connection>(
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* NOTE: This must not be called on the main thread because it is blocking!
|
||||||
|
*
|
||||||
* @return true if the connection was SUCCESS. False if the handshake poller should immediately close the publication
|
* @return true if the connection was SUCCESS. False if the handshake poller should immediately close the publication
|
||||||
*/
|
*/
|
||||||
fun processIpcHandshakeMessageServer(
|
fun processIpcHandshakeMessageServer(
|
||||||
|
@ -331,6 +333,7 @@ internal class ServerHandshake<CONNECTION : Connection>(
|
||||||
var newConnection: CONNECTION? = null
|
var newConnection: CONNECTION? = null
|
||||||
try {
|
try {
|
||||||
// Create a pub/sub at the given address and port, using the given stream ID.
|
// Create a pub/sub at the given address and port, using the given stream ID.
|
||||||
|
// NOTE: This must not be called on the main thread because it is blocking!
|
||||||
val newConnectionDriver = ServerConnectionDriver.build(
|
val newConnectionDriver = ServerConnectionDriver.build(
|
||||||
aeronDriver = aeronDriver,
|
aeronDriver = aeronDriver,
|
||||||
ipInfo = server.ipInfo,
|
ipInfo = server.ipInfo,
|
||||||
|
@ -422,7 +425,7 @@ internal class ServerHandshake<CONNECTION : Connection>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* note: CANNOT be called in action dispatch. ALWAYS ON SAME THREAD
|
* NOTE: This must not be called on the main thread because it is blocking!
|
||||||
*
|
*
|
||||||
* @return true if the connection was SUCCESS. False if the handshake poller should immediately close the publication
|
* @return true if the connection was SUCCESS. False if the handshake poller should immediately close the publication
|
||||||
*/
|
*/
|
||||||
|
@ -585,6 +588,7 @@ internal class ServerHandshake<CONNECTION : Connection>(
|
||||||
var newConnection: CONNECTION? = null
|
var newConnection: CONNECTION? = null
|
||||||
try {
|
try {
|
||||||
// Create a pub/sub at the given address and port, using the given stream ID.
|
// Create a pub/sub at the given address and port, using the given stream ID.
|
||||||
|
// NOTE: This must not be called on the main thread because it is blocking!
|
||||||
val newConnectionDriver = ServerConnectionDriver.build(
|
val newConnectionDriver = ServerConnectionDriver.build(
|
||||||
ipInfo = server.ipInfo,
|
ipInfo = server.ipInfo,
|
||||||
aeronDriver = aeronDriver,
|
aeronDriver = aeronDriver,
|
||||||
|
|
|
@ -26,6 +26,7 @@ import dorkbox.network.aeron.AeronDriver
|
||||||
import dorkbox.network.aeron.AeronDriver.Companion.uriHandshake
|
import dorkbox.network.aeron.AeronDriver.Companion.uriHandshake
|
||||||
import dorkbox.network.aeron.AeronPoller
|
import dorkbox.network.aeron.AeronPoller
|
||||||
import dorkbox.network.connection.Connection
|
import dorkbox.network.connection.Connection
|
||||||
|
import dorkbox.network.connection.EventDispatcher
|
||||||
import dorkbox.network.connection.IpInfo
|
import dorkbox.network.connection.IpInfo
|
||||||
import dorkbox.network.exceptions.ServerException
|
import dorkbox.network.exceptions.ServerException
|
||||||
import dorkbox.network.exceptions.ServerHandshakeException
|
import dorkbox.network.exceptions.ServerHandshakeException
|
||||||
|
@ -115,63 +116,84 @@ internal object ServerHandshakePollers {
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
driver.deleteLogFile(image)
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// we have read all the data, now dispatch it.
|
|
||||||
// HandshakeMessage.HELLO
|
|
||||||
// HandshakeMessage.DONE
|
|
||||||
val messageState = message.state
|
|
||||||
val connectKey = message.connectKey
|
|
||||||
|
|
||||||
if (messageState == HandshakeMessage.HELLO) {
|
// NOTE: This MUST to happen in separates thread so that we can take as long as we need when creating publications and handshaking,
|
||||||
// we create a NEW publication for the handshake, which connects directly to the client handshake subscription
|
// because under load -- this will REGULARLY timeout! Under no circumstance can this happen in the main processing thread!!
|
||||||
|
EventDispatcher.MULTI.launch {
|
||||||
|
// we have read all the data, now dispatch it.
|
||||||
|
// HandshakeMessage.HELLO
|
||||||
|
// HandshakeMessage.DONE
|
||||||
|
val messageState = message.state
|
||||||
|
val connectKey = message.connectKey
|
||||||
|
|
||||||
val publicationUri = uriHandshake(CommonContext.IPC_MEDIA, isReliable)
|
|
||||||
|
|
||||||
// this will always connect to the CLIENT handshake subscription!
|
if (messageState == HandshakeMessage.HELLO) {
|
||||||
val publication = try {
|
// we create a NEW publication for the handshake, which connects directly to the client handshake subscription
|
||||||
driver.addExclusivePublication(publicationUri, message.streamId, logInfo, true)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
|
||||||
driver.deleteLogFile(image)
|
|
||||||
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Cannot create IPC publication back to client remote process", e))
|
val publicationUri = uriHandshake(CommonContext.IPC_MEDIA, isReliable)
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
// this will always connect to the CLIENT handshake subscription!
|
||||||
// we actually have to wait for it to connect before we continue
|
val publication = try {
|
||||||
driver.waitForConnection(publication, handshakeTimeoutNs, logInfo) { cause ->
|
driver.addExclusivePublication(publicationUri, message.streamId, logInfo, true)
|
||||||
ServerTimedoutException("$logInfo publication cannot connect with client in ${Sys.getTimePrettyFull(handshakeTimeoutNs)}", cause)
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
catch (e: Exception) {
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
driver.deleteLogFile(image)
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Cannot create IPC publication back to client remote process", e))
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Cannot create IPC publication back to client remote process", e))
|
||||||
return
|
return@launch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// we actually have to wait for it to connect before we continue
|
||||||
|
driver.waitForConnection(publication, handshakeTimeoutNs, logInfo) { cause ->
|
||||||
|
ServerTimedoutException("$logInfo publication cannot connect with client in ${Sys.getTimePrettyFull(handshakeTimeoutNs)}", cause)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Cannot create IPC publication back to client remote process", e))
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val success = handshake.processIpcHandshakeMessageServer(
|
val success = handshake.processIpcHandshakeMessageServer(
|
||||||
server = server,
|
server = server,
|
||||||
handshaker = handshaker,
|
handshaker = handshaker,
|
||||||
aeronDriver = driver,
|
aeronDriver = driver,
|
||||||
handshakePublication = publication,
|
handshakePublication = publication,
|
||||||
publicKey = message.publicKey!!,
|
publicKey = message.publicKey!!,
|
||||||
message = message,
|
message = message,
|
||||||
logInfo = logInfo,
|
logInfo = logInfo,
|
||||||
logger = logger
|
logger = logger
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
publications[connectKey] = publication
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
// we might not be able to close this connection.
|
||||||
|
driver.close(publication, logInfo)
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
server.listenerManager.notifyError(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
if (success) {
|
|
||||||
publications[connectKey] = publication
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
// we might not be able to close this connection.
|
// we might not be able to close this connection.
|
||||||
driver.close(publication, logInfo)
|
driver.close(publication, logInfo)
|
||||||
|
@ -179,8 +201,35 @@ internal object ServerHandshakePollers {
|
||||||
catch (e: Exception) {
|
catch (e: Exception) {
|
||||||
server.listenerManager.notifyError(e)
|
server.listenerManager.notifyError(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Error processing IPC handshake", e))
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} else {
|
||||||
|
// HandshakeMessage.DONE
|
||||||
|
|
||||||
|
val publication = publications.remove(connectKey)
|
||||||
|
if (publication == null) {
|
||||||
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] No publication back to IPC"))
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
handshake.validateMessageTypeAndDoPending(
|
||||||
|
server = server,
|
||||||
|
handshaker = handshaker,
|
||||||
|
handshakePublication = publication,
|
||||||
|
message = message,
|
||||||
|
logInfo = logInfo,
|
||||||
|
logger = logger
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Error processing IPC handshake", e))
|
||||||
|
}
|
||||||
|
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
driver.deleteLogFile(image)
|
driver.deleteLogFile(image)
|
||||||
|
@ -192,45 +241,6 @@ internal object ServerHandshakePollers {
|
||||||
catch (e: Exception) {
|
catch (e: Exception) {
|
||||||
server.listenerManager.notifyError(e)
|
server.listenerManager.notifyError(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Error processing IPC handshake", e))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// HandshakeMessage.DONE
|
|
||||||
|
|
||||||
val publication = publications.remove(connectKey)
|
|
||||||
if (publication == null) {
|
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
|
||||||
driver.deleteLogFile(image)
|
|
||||||
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] No publication back to IPC"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
handshake.validateMessageTypeAndDoPending(
|
|
||||||
server = server,
|
|
||||||
handshaker = handshaker,
|
|
||||||
handshakePublication = publication,
|
|
||||||
message = message,
|
|
||||||
logInfo = logInfo,
|
|
||||||
logger = logger
|
|
||||||
)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Error processing IPC handshake", e))
|
|
||||||
}
|
|
||||||
|
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
|
||||||
driver.deleteLogFile(image)
|
|
||||||
|
|
||||||
try {
|
|
||||||
// we might not be able to close this connection.
|
|
||||||
driver.close(publication, logInfo)
|
|
||||||
}
|
|
||||||
catch (e: Exception) {
|
|
||||||
server.listenerManager.notifyError(e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -365,68 +375,84 @@ internal object ServerHandshakePollers {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: This MUST to happen in separates thread so that we can take as long as we need when creating publications and handshaking,
|
||||||
|
// because under load -- this will REGULARLY timeout! Under no circumstance can this happen in the main processing thread!!
|
||||||
|
EventDispatcher.MULTI.launch {
|
||||||
|
// HandshakeMessage.HELLO
|
||||||
|
// HandshakeMessage.DONE
|
||||||
|
val messageState = message.state
|
||||||
|
val connectKey = message.connectKey
|
||||||
|
|
||||||
// HandshakeMessage.HELLO
|
if (messageState == HandshakeMessage.HELLO) {
|
||||||
// HandshakeMessage.DONE
|
// we create a NEW publication for the handshake, which connects directly to the client handshake subscription
|
||||||
val messageState = message.state
|
|
||||||
val connectKey = message.connectKey
|
|
||||||
|
|
||||||
if (messageState == HandshakeMessage.HELLO) {
|
// we explicitly have the publisher "connect to itself", because we are using MDC to work around NAT.
|
||||||
// we create a NEW publication for the handshake, which connects directly to the client handshake subscription
|
// It will "auto-connect" to the correct client port (negotiated by the MDC client subscription negotiating on the
|
||||||
|
// control port of the server)
|
||||||
// we explicitly have the publisher "connect to itself", because we are using MDC to work around NAT.
|
val publicationUri = uriHandshake(CommonContext.UDP_MEDIA, isReliable)
|
||||||
// It will "auto-connect" to the correct client port (negotiated by the MDC client subscription negotiating on the
|
.controlEndpoint(ipInfo.getAeronPubAddress(isRemoteIpv4) + ":" + mdcPortPub)
|
||||||
// control port of the server)
|
|
||||||
val publicationUri = uriHandshake(CommonContext.UDP_MEDIA, isReliable)
|
|
||||||
.controlEndpoint(ipInfo.getAeronPubAddress(isRemoteIpv4) + ":" + mdcPortPub)
|
|
||||||
|
|
||||||
|
|
||||||
// this will always connect to the CLIENT handshake subscription!
|
// this will always connect to the CLIENT handshake subscription!
|
||||||
val publication = try {
|
val publication = try {
|
||||||
driver.addExclusivePublication(publicationUri, message.streamId, logInfo, false)
|
driver.addExclusivePublication(publicationUri, message.streamId, logInfo, false)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
driver.deleteLogFile(image)
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Cannot create publication back to $clientAddressString", e))
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Cannot create publication back to $clientAddressString", e))
|
||||||
return
|
return@launch
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// we actually have to wait for it to connect before we continue
|
|
||||||
driver.waitForConnection(publication, handshakeTimeoutNs, logInfo) { cause ->
|
|
||||||
ServerTimedoutException("$logInfo publication cannot connect with client in ${Sys.getTimePrettyFull(handshakeTimeoutNs)}", cause)
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
|
||||||
driver.deleteLogFile(image)
|
|
||||||
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Cannot create publication back to $clientAddressString", e))
|
try {
|
||||||
return
|
// we actually have to wait for it to connect before we continue.
|
||||||
}
|
//
|
||||||
|
driver.waitForConnection(publication, handshakeTimeoutNs, logInfo) { cause ->
|
||||||
|
ServerTimedoutException("$logInfo publication cannot connect with client in ${Sys.getTimePrettyFull(handshakeTimeoutNs)}", cause)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
try {
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Cannot create publication back to $clientAddressString", e))
|
||||||
val success = handshake.processUdpHandshakeMessageServer(
|
return@launch
|
||||||
server = server,
|
}
|
||||||
handshaker = handshaker,
|
|
||||||
handshakePublication = publication,
|
|
||||||
publicKey = message.publicKey!!,
|
|
||||||
clientAddress = clientAddress,
|
|
||||||
clientAddressString = clientAddressString,
|
|
||||||
portPub = message.port,
|
|
||||||
portSub = serverPortSub,
|
|
||||||
mdcPortPub = mdcPortPub,
|
|
||||||
isReliable = isReliable,
|
|
||||||
message = message,
|
|
||||||
logInfo = logInfo,
|
|
||||||
logger = logger
|
|
||||||
)
|
|
||||||
|
|
||||||
if (success) {
|
try {
|
||||||
publications[connectKey] = publication
|
val success = handshake.processUdpHandshakeMessageServer(
|
||||||
} else {
|
server = server,
|
||||||
|
handshaker = handshaker,
|
||||||
|
handshakePublication = publication,
|
||||||
|
publicKey = message.publicKey!!,
|
||||||
|
clientAddress = clientAddress,
|
||||||
|
clientAddressString = clientAddressString,
|
||||||
|
portPub = message.port,
|
||||||
|
portSub = serverPortSub,
|
||||||
|
mdcPortPub = mdcPortPub,
|
||||||
|
isReliable = isReliable,
|
||||||
|
message = message,
|
||||||
|
logInfo = logInfo,
|
||||||
|
logger = logger
|
||||||
|
)
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
publications[connectKey] = publication
|
||||||
|
} else {
|
||||||
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
|
try {
|
||||||
|
// we might not be able to close this connection.
|
||||||
|
driver.close(publication, logInfo)
|
||||||
|
}
|
||||||
|
catch (e: Exception) {
|
||||||
|
server.listenerManager.notifyError(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
driver.deleteLogFile(image)
|
driver.deleteLogFile(image)
|
||||||
|
@ -436,62 +462,50 @@ internal object ServerHandshakePollers {
|
||||||
driver.close(publication, logInfo)
|
driver.close(publication, logInfo)
|
||||||
}
|
}
|
||||||
catch (e: Exception) {
|
catch (e: Exception) {
|
||||||
server.listenerManager.notifyError(e)
|
driver.close(publication, logInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Error processing IPC handshake", e))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// HandshakeMessage.DONE
|
||||||
|
|
||||||
|
val publication = publications.remove(connectKey)
|
||||||
|
|
||||||
|
if (publication == null) {
|
||||||
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] No publication back to $clientAddressString"))
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
handshake.validateMessageTypeAndDoPending(
|
||||||
|
server = server,
|
||||||
|
handshaker = handshaker,
|
||||||
|
handshakePublication = publication,
|
||||||
|
message = message,
|
||||||
|
logInfo = logInfo,
|
||||||
|
logger = logger
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Error processing IPC handshake", e))
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
|
||||||
driver.deleteLogFile(image)
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// we might not be able to close this connection.
|
// we might not be able to close this connection.
|
||||||
driver.close(publication, logInfo)
|
driver.close(publication, logInfo)
|
||||||
}
|
}
|
||||||
catch (e: Exception) {
|
catch (e: Exception) {
|
||||||
driver.close(publication, logInfo)
|
server.listenerManager.notifyError(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Error processing IPC handshake", e))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// HandshakeMessage.DONE
|
|
||||||
|
|
||||||
val publication = publications.remove(connectKey)
|
|
||||||
|
|
||||||
if (publication == null) {
|
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
||||||
driver.deleteLogFile(image)
|
driver.deleteLogFile(image)
|
||||||
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] No publication back to $clientAddressString"))
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
handshake.validateMessageTypeAndDoPending(
|
|
||||||
server = server,
|
|
||||||
handshaker = handshaker,
|
|
||||||
handshakePublication = publication,
|
|
||||||
message = message,
|
|
||||||
logInfo = logInfo,
|
|
||||||
logger = logger
|
|
||||||
)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
server.listenerManager.notifyError(ServerHandshakeException("[$logInfo] Error processing IPC handshake", e))
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// we might not be able to close this connection.
|
|
||||||
driver.close(publication, logInfo)
|
|
||||||
}
|
|
||||||
catch (e: Exception) {
|
|
||||||
server.listenerManager.notifyError(e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// we should immediately remove the logbuffer for this! Aeron will **EVENTUALLY** remove the logbuffer, but if errors
|
|
||||||
// and connections occur too quickly (within the cleanup/linger period), we can run out of memory!
|
|
||||||
driver.deleteLogFile(image)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue