chiark / gitweb /
timedread: Retry on EINTR from poll
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 May 2021 10:01:00 +0000 (11:01 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 May 2021 10:08:39 +0000 (11:08 +0100)
In test failures which occurred before I introeduced
  packetframe: Fuse: Do not persist EINTR or EWOULDBLOCK
I think I observed poll() returning EINTR.  Better to handle
that here even if the next layer up might do so.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/timedread.rs

index 1a6c6874a51f0e5379a5db89615d12a4cc06447f..b42782326b917b80a3f50c06929e6866f3f66c06 100644 (file)
@@ -97,7 +97,13 @@ impl Read for TimedFdReader {
       } else {
         None
       };
-      self.poll.poll(&mut self.events, timeout)?;
+      loop {
+        match self.poll.poll(&mut self.events, timeout) {
+          Err(e) if e.kind() == ErrorKind::Interrupted => continue,
+          Err(e) => throw!(e),
+          Ok(()) => break,
+        }
+      }
       if self.events.is_empty() { throw!(io::ErrorKind::TimedOut) }
     }
   }