Skip to content

Commit

Permalink
fix: close connection after encountering an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
lost-illusi0n committed Jan 7, 2024
1 parent b6dd8cc commit 71baac4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import dev.sitar.kmail.message.Message
import dev.sitar.kmail.utils.connection.Connection
import dev.sitar.kmail.utils.io.readStringUtf8
import dev.sitar.kmail.utils.io.readUtf8UntilLineEnd
import kotlinx.coroutines.cancel
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.isActive
import mu.KotlinLogging
Expand All @@ -38,6 +39,8 @@ class ImapServerTransport(var connection: Connection) {
commandPipeline.process(context)
} catch (e: Exception) {
logger.error(e) { "imap transport stream encountered exception." }

cancel()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import dev.sitar.kmail.pop3.io.asPop3ServerReader
import dev.sitar.kmail.pop3.io.asPop3ServerWriter
import dev.sitar.kmail.pop3.replies.Pop3Reply
import dev.sitar.kmail.utils.connection.Connection
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.coroutines.*
import mu.KotlinLogging

private val logger = KotlinLogging.logger { }
Expand All @@ -30,6 +27,8 @@ class Pop3ServerTransport(val connection: Connection) {
commandPipeline.process(context)
} catch (e: Exception) {
logger.error(e) { "pop3 transport stream encountered exception." }

cancel()
}
}
}
Expand Down

0 comments on commit 71baac4

Please sign in to comment.