Avoid inconsistent state check

This commit is contained in:
Sergey Mashkov
2019-08-26 13:39:54 +03:00
parent ab91da5c78
commit e8c33fe5a3

View File

@@ -1870,8 +1870,10 @@ internal class ByteBufferChannel(
try {
result = visitor(this)
} finally {
if (!state.idle && state !== ReadWriteBufferState.Terminated) {
if (state is ReadWriteBufferState.Reading || state is ReadWriteBufferState.ReadingWriting) {
val stateSnapshot = state
if (!stateSnapshot.idle && stateSnapshot !== ReadWriteBufferState.Terminated) {
if (stateSnapshot is ReadWriteBufferState.Reading || stateSnapshot is ReadWriteBufferState.ReadingWriting) {
restoreStateAfterRead()
}
tryTerminate()