From 3e4e4abb49dc3ddc32019820a536abf0841d5725 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 9 Sep 2020 02:01:06 +0200 Subject: [PATCH] Fixed issue when publication has intermittent subscribers (this can happen, and is OK). During send we just have to idle until one is connected again. This is different than a CLOSE event (which is not to be confused with NOT_CONNECTED) --- src/dorkbox/network/connection/EndPoint.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/dorkbox/network/connection/EndPoint.kt b/src/dorkbox/network/connection/EndPoint.kt index ec90e8b9..03c501c6 100644 --- a/src/dorkbox/network/connection/EndPoint.kt +++ b/src/dorkbox/network/connection/EndPoint.kt @@ -656,8 +656,19 @@ internal constructor(val type: Class<*>, internal val config: Configuration) : A return } - if (result == Publication.BACK_PRESSURED || result == Publication.ADMIN_ACTION) { - // we should retry. + /** + * The publication is not connected to a subscriber, this can be an intermittent state as subscribers come and go. + * val NOT_CONNECTED: Long = -1 + * + * The offer failed due to back pressure from the subscribers preventing further transmission. + * val BACK_PRESSURED: Long = -2 + * + * The offer failed due to an administration action and should be retried. + * The action is an operation such as log rotation which is likely to have succeeded by the next retry attempt. + * val ADMIN_ACTION: Long = -3 + */ + if (result >= Publication.ADMIN_ACTION) { + // we should retry, BUT we want suspend ANYONE ELSE trying to write at the same time! sendIdleStrategy.idle() continue }