Skip to content

Commit 6165533

Browse files
authored
Fix non-linearizability in BufferedChannel.expandBuffer() (#3730)
Signed-off-by: Nikita Koval <[email protected]>
1 parent a027d68 commit 6165533

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kotlinx-coroutines-core/common/src/channels/BufferedChannel.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1220,9 +1220,9 @@ internal open class BufferedChannel<E>(
12201220
incCompletedExpandBufferAttempts()
12211221
return
12221222
}
1223-
// Is `bufferEndSegment` outdated?
1223+
// Is `bufferEndSegment` outdated or is the segment with the required id already removed?
12241224
// Find the required segment, creating new ones if needed.
1225-
if (segment.id < id) {
1225+
if (segment.id != id) {
12261226
segment = findSegmentBufferEnd(id, segment, b)
12271227
// Restart if the required segment is removed, or
12281228
// the linked list of segments is already closed,

0 commit comments

Comments
 (0)