Skip to content

Commit 47d92ba

Browse files
author
Sergey Mashkov
committed
IO: fix race in closeWaitJob of JoiningState
1 parent d42bdad commit 47d92ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1973,7 +1973,10 @@ internal class ByteBufferChannel(
19731973
val current = _closeWaitJob.value
19741974
if (current != null) return current
19751975
val newJob = Job()
1976-
if (_closeWaitJob.compareAndSet(null, newJob)) return newJob
1976+
if (_closeWaitJob.compareAndSet(null, newJob)) {
1977+
if (closed.value == 1) newJob.cancel()
1978+
return newJob
1979+
}
19771980
}
19781981
}
19791982

0 commit comments

Comments
 (0)