From e99448e066a4a6e198dfa3d794abf8ddb2be869f Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 3 Sep 2020 15:31:52 +0200 Subject: [PATCH] Only configure the media driver context to delete the dirs if this is the process that started it --- src/dorkbox/network/connection/EndPoint.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/dorkbox/network/connection/EndPoint.kt b/src/dorkbox/network/connection/EndPoint.kt index 150ff26f..cb969032 100644 --- a/src/dorkbox/network/connection/EndPoint.kt +++ b/src/dorkbox/network/connection/EndPoint.kt @@ -118,7 +118,7 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A internal val listenerManager = ListenerManager() internal val connections = ConnectionManager() - internal var mediaDriverContext: MediaDriver.Context? = null + internal val mediaDriverContext: MediaDriver.Context private var mediaDriver: MediaDriver? = null private var aeron: Aeron? = null @@ -250,8 +250,6 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A val mDrivercontext = MediaDriver.Context() .publicationReservedSessionIdLow(RESERVED_SESSION_ID_LOW) .publicationReservedSessionIdHigh(RESERVED_SESSION_ID_HIGH) - .dirDeleteOnStart(true) - .dirDeleteOnShutdown(true) .conductorThreadFactory(threadFactory) .receiverThreadFactory(threadFactory) .senderThreadFactory(threadFactory) @@ -294,10 +292,15 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A val aeronDirectory = config.aeronLogDirectory!!.absolutePath if (!isRunning()) { + logger.debug { "Starting Aeron Media driver..."} + + mediaDriverContext + .dirDeleteOnStart(true) + .dirDeleteOnShutdown(true) + // the server always creates a the media driver. - mediaDriver = try { - logger.debug { "Starting Aeron Media driver..."} - MediaDriver.launch(mediaDriverContext) + try { + mediaDriver = MediaDriver.launch(mediaDriverContext) } catch (e: Exception) { listenerManager.notifyError(e) throw e