Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

## Fixed 🐛

- Drain tty fd to `WouldBlock` so large pastes don't stall under edge-triggered epoll (#1057)

# Version 0.29

## Added ⭐
Expand Down
13 changes: 10 additions & 3 deletions src/event/source/unix/mio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ impl EventSource for UnixInternalEventSource {
for token in self.events.iter().map(|x| x.token()) {
match token {
TTY_TOKEN => {
// mio uses edge-triggered epoll on Linux; drain to
// WouldBlock before returning, or buffered bytes
// stay unread until the next edge.
loop {
match self.tty_fd.read(&mut self.tty_buffer) {
Ok(read_count) => {
Expand All @@ -102,6 +105,10 @@ impl EventSource for UnixInternalEventSource {
read_count == TTY_BUFFER_SIZE,
);
}
if read_count < TTY_BUFFER_SIZE {
// Short read on a tty: nothing more buffered.
break;
}
}
Err(e) => {
// No more data to read at the moment. We will receive another event
Expand All @@ -114,10 +121,10 @@ impl EventSource for UnixInternalEventSource {
}
}
};
}

if let Some(event) = self.parser.next() {
return Ok(Some(event));
}
if let Some(event) = self.parser.next() {
return Ok(Some(event));
}
}
SIGNAL_TOKEN => {
Expand Down