summaryrefslogtreecommitdiffstats
path: root/tokio/src/io/driver/mod.rs
diff options
context:
space:
mode:
authorKevin Leimkuhler <kevin@kleimkuhler.com>2020-02-25 13:27:44 -0800
committerGitHub <noreply@github.com>2020-02-25 13:27:44 -0800
commit10f1507cf44b62f4b126ecdd28351e4a4a1ce3f7 (patch)
tree894d55b06d40eec7c1a23da33d8c05d410a892b2 /tokio/src/io/driver/mod.rs
parentb9cc032d3bcf7686f0130163c13d3d660d30ae2c (diff)
process: Wake up read and write on `EPOLLERR` (#2218)
## Motivation #2174 On epoll platforms, the read end of a pipe closing is signaled to the write end through the `EPOLLERR` event [[1](http://man7.org/linux/man-pages/man2/epoll_ctl.2.html)]. If readiness is not registered for this event, it will silently pass through `epoll_wait` calls. Additionally, this specific case that `EPOLLERR` is triggered leaves the write end of the pipe (parent process) waiting for a wakeup that never occurs. ## Solution Similar to the `HUP` event on Unix platforms, errors are now always masked through registrations so that both read and write ends of a connection are made aware of errors. In cases where pipes are used and the read end closes, write ends that are waiting for a wakeup are properly notified and try to write again. This allows a client to observe `BrokenPipe` and go through the proper cleanup and/or restablishment of connection. Closes #2174 Signed-off-by: Kevin Leimkuhler <kevin@kleimkuhler.com>
Diffstat (limited to 'tokio/src/io/driver/mod.rs')
-rw-r--r--tokio/src/io/driver/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tokio/src/io/driver/mod.rs b/tokio/src/io/driver/mod.rs
index e707d3a5..d8535d9a 100644
--- a/tokio/src/io/driver/mod.rs
+++ b/tokio/src/io/driver/mod.rs
@@ -146,7 +146,7 @@ impl Driver {
return;
}
- if ready.is_writable() || platform::is_hup(ready) {
+ if ready.is_writable() || platform::is_hup(ready) || platform::is_error(ready) {
wr = io.writer.take_waker();
}
@@ -293,7 +293,7 @@ impl Direction {
// Everything except writable is signaled through read.
mio::Ready::all() - mio::Ready::writable()
}
- Direction::Write => mio::Ready::writable() | platform::hup(),
+ Direction::Write => mio::Ready::writable() | platform::hup() | platform::error(),
}
}
}