Skip to content

Commit a5e45ee

Browse files
committed
minor change in ktor tcp
1 parent 6d263e7 commit a5e45ee

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpClientTransport.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private class KtorTcpClientTargetImpl(
9797
return withContext(Dispatchers.IoCompatible) {
9898
val socket = aSocket(selectorManager).tcp().connect(remoteAddress, socketOptions)
9999
KtorTcpConnection(
100-
coroutineContext = this@KtorTcpClientTargetImpl.coroutineContext.childContext(),
100+
parentContext = this@KtorTcpClientTargetImpl.coroutineContext,
101101
socket = socket
102102
)
103103
}

rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpConnection.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ import kotlin.coroutines.*
2828

2929
@RSocketTransportApi
3030
internal class KtorTcpConnection(
31-
override val coroutineContext: CoroutineContext,
31+
parentContext: CoroutineContext,
3232
private val socket: Socket,
3333
) : RSocketSequentialConnection {
3434
private val outboundQueue = PrioritizationFrameQueue(Channel.BUFFERED)
3535
private val inbound = bufferChannel(Channel.BUFFERED)
3636

37+
override val coroutineContext: CoroutineContext = parentContext.childContext()
38+
3739
init {
3840
@OptIn(DelicateCoroutinesApi::class)
3941
launch(start = CoroutineStart.ATOMIC) {

rsocket-transports/ktor-tcp/src/commonMain/kotlin/io/rsocket/kotlin/transport/ktor/tcp/KtorTcpServerTransport.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,12 @@ private class KtorTcpServerInstanceImpl(
129129
val connectionsContext = currentCoroutineContext().supervisorContext()
130130
while (true) {
131131
val socket = serverSocket.accept()
132-
onConnection(KtorTcpConnection(connectionsContext.childContext(), socket))
132+
onConnection(
133+
KtorTcpConnection(
134+
parentContext = connectionsContext,
135+
socket = socket
136+
)
137+
)
133138
}
134139
} finally {
135140
nonCancellable {

0 commit comments

Comments
 (0)