Skip to content

Commit

Permalink
KTOR-8105 Fix concurrent flush attempts corrupting segment pool
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhham committed Jan 30, 2025
1 parent e4fd251 commit 1c4f5b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ internal abstract class NIOSocketImpl<out S>(
override fun close() {
if (!closeFlag.compareAndSet(false, true)) return

readerJob.get()?.channel?.close()
writerJob.get()?.cancel()
checkChannels()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package io.ktor.network.sockets.tests

import io.ktor.network.selector.*
import io.ktor.network.sockets.*
import io.ktor.util.cio.*
import io.ktor.utils.io.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.junit5.CoroutinesTimeout
Expand All @@ -15,7 +16,6 @@ import java.nio.channels.ClosedChannelException
import java.util.concurrent.CancellationException
import java.util.concurrent.CountDownLatch
import java.util.concurrent.Executors
import kotlin.concurrent.Volatile
import kotlin.concurrent.thread
import kotlin.coroutines.CoroutineContext
import kotlin.test.AfterTest
Expand Down Expand Up @@ -90,8 +90,9 @@ class ServerSocketTest : CoroutineScope {
@Test
fun testWrite() {
val server = server { client ->
val channel = client.openWriteChannel(true)
channel.writeStringUtf8("123")
client.openWriteChannel(true).use {
writeStringUtf8("123")
}
}

client { socket ->
Expand Down

0 comments on commit 1c4f5b9

Please sign in to comment.