Skip to content

Commit 466fe29

Browse files
committed
Handle EINTR.
When building with sccache locally, I'm seeing a bunch of errors to acquire the jobserver token which are caused by interrupts at bad times. I think it was a kernel update what caused this, fwiw, but not 100% sure. Both can happen according to the man pages, and we're not handling them sensibly. I think retrying the read / poll when the error is EINTR is a sensible thing to do.
1 parent b7d8bc9 commit 466fe29

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,11 @@ mod imp {
591591
loop {
592592
fd.revents = 0;
593593
if libc::poll(&mut fd, 1, -1) == -1 {
594-
return Err(io::Error::last_os_error());
594+
let e = io::Error::last_os_error();
595+
match e.kind() {
596+
io::ErrorKind::Interrupted => continue,
597+
_ => return Err(e),
598+
}
595599
}
596600
if fd.revents == 0 {
597601
continue;
@@ -605,8 +609,11 @@ mod imp {
605609
"early EOF on jobserver pipe",
606610
))
607611
}
608-
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {}
609-
Err(e) => return Err(e),
612+
Err(e) => match e.kind() {
613+
io::ErrorKind::WouldBlock |
614+
io::ErrorKind::Interrupted => continue,
615+
_ => return Err(e),
616+
},
610617
}
611618
}
612619
}

0 commit comments

Comments
 (0)