mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
poll: Do not clear readiness on short read/writes. (#5881)
The new mio_unsupported_force_poll_poll behaviour works the same as Windows (using level-triggered APIs to mimic edge-triggered ones) and it depends on intercepting an EAGAIN result to start polling the fd again.
This commit is contained in:
@@ -165,8 +165,10 @@ feature! {
|
|||||||
match self.io.as_ref().unwrap().read(b) {
|
match self.io.as_ref().unwrap().read(b) {
|
||||||
Ok(n) => {
|
Ok(n) => {
|
||||||
// if we read a partially full buffer, this is sufficient on unix to show
|
// if we read a partially full buffer, this is sufficient on unix to show
|
||||||
// that the socket buffer has been drained
|
// that the socket buffer has been drained. Unfortunately this assumption
|
||||||
if n > 0 && (!cfg!(windows) && n < len) {
|
// fails for level-triggered selectors (like on Windows or poll even for
|
||||||
|
// UNIX): https://github.com/tokio-rs/tokio/issues/5866
|
||||||
|
if n > 0 && (!cfg!(windows) && !cfg!(mio_unsupported_force_poll_poll) && n < len) {
|
||||||
self.registration.clear_readiness(evt);
|
self.registration.clear_readiness(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,8 +198,10 @@ feature! {
|
|||||||
match self.io.as_ref().unwrap().write(buf) {
|
match self.io.as_ref().unwrap().write(buf) {
|
||||||
Ok(n) => {
|
Ok(n) => {
|
||||||
// if we write only part of our buffer, this is sufficient on unix to show
|
// if we write only part of our buffer, this is sufficient on unix to show
|
||||||
// that the socket buffer is full
|
// that the socket buffer is full. Unfortunately this assumption
|
||||||
if n > 0 && (!cfg!(windows) && n < buf.len()) {
|
// fails for level-triggered selectors (like on Windows or poll even for
|
||||||
|
// UNIX): https://github.com/tokio-rs/tokio/issues/5866
|
||||||
|
if n > 0 && (!cfg!(windows) && !cfg!(mio_unsupported_force_poll_poll) && n < buf.len()) {
|
||||||
self.registration.clear_readiness(evt);
|
self.registration.clear_readiness(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user