Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
io: wake pending writers on DuplexStream close
Performing a write on a closed DuplexStream (i.e. other end is dropped) results in an Err(BrokenPipe). However, if there is a writer waiting to be awoken from a buffer-full condition, it would previously be ignored, and thus stuck in suspended state, as no further reads could ever be made. Split the Pipe::close routine into close_read and close_write, and perform both in case one side of the DuplexStream is dropped. close_read will notify any writers to wake up, which will then cause them to see the updated is_closed flag and return an Err(BrokenPipe) immediately. Test case 'disconnect_reader' is added to test the fixed behaviour, it would previously get stuck indefinitely. The 'max_write_size' test needs to be updated with a notify barrier, as otherwise the read side is dropped immediately after performing the read_exact, which now resulted in the second write being awoken and failing with a BrokenPipe error.
- Loading branch information
Showing
2 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters