Browse Source
Before this commit, ReadCompletionHandler delayed closing the channel to allow an ongoing read to complete/fail so we can get a hold of the associated DataBuffer and release it. This can be problematic since the read take time to complete but even more importantly there was a race condition where we didn't check if we've been disposed concurrently while releasing the read flag. This commit removes the delay and closes the channel immediately from cancel() and that should in turn fail any ongoing read operation, according to AsynchronousChannel, and the DataBuffer is released. Further improvements include: - combining the "reading" and "disposed" AtomicBoolean's into a single "state" AtomicReference. - an optimistic check to remain in READING mode and avoid state switches when there is demand to continue reading. Closes gh-25831pull/26273/head
1 changed files with 59 additions and 46 deletions
Loading…
Reference in new issue