Skip to content

Commit 18b28a2

Browse files
author
Sergey Mashkov
committed
IO: make byte channel detect closed state earlier
1 parent a4d45d2 commit 18b28a2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/kotlinx-coroutines-io/src/main/kotlin/kotlinx/coroutines/experimental/io/ByteBufferChannel.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ internal class ByteBufferChannel(
142142
}
143143
}
144144

145+
if (closed != null) {
146+
restoreStateAfterWrite()
147+
tryTerminate()
148+
149+
throw closed!!.sendException
150+
}
151+
145152
val buffer = newState.writeBuffer
146153

147154
_allocated?.let { allocated ->

0 commit comments

Comments
 (0)