Skip to content

Commit 42b8a1e

Browse files
committed
fix(net): ignore EINTR errno response from select (#276)
1 parent 7c88eba commit 42b8a1e

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/tracing/net/platform/unix.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use nix::{
88
sys::select::FdSet,
99
sys::socket::{AddressFamily, SockaddrLike},
1010
sys::time::{TimeVal, TimeValLike},
11+
Error,
1112
};
1213
use socket2::{Domain, Protocol, SockAddr, Type};
1314
use std::io;
@@ -305,9 +306,15 @@ impl TracerSocket for Socket {
305306
None,
306307
None,
307308
Some(&mut TimeVal::milliseconds(timeout.as_millis() as i64)),
308-
)
309-
.map_err(|err| IoError::Other(std::io::Error::from(err), IoOperation::Select))?;
310-
Ok(readable == 1)
309+
);
310+
match readable {
311+
Ok(readable) => Ok(readable == 1),
312+
Err(err) if err == Error::EINTR => Ok(false),
313+
Err(err) => Err(IoError::Other(
314+
std::io::Error::from(err),
315+
IoOperation::Select,
316+
)),
317+
}
311318
}
312319
#[instrument(skip(self))]
313320
fn is_writable(&self) -> IoResult<bool> {
@@ -319,9 +326,15 @@ impl TracerSocket for Socket {
319326
Some(&mut write),
320327
None,
321328
Some(&mut TimeVal::zero()),
322-
)
323-
.map_err(|err| IoError::Other(std::io::Error::from(err), IoOperation::Select))?;
324-
Ok(writable == 1)
329+
);
330+
match writable {
331+
Ok(writable) => Ok(writable == 1),
332+
Err(err) if err == Error::EINTR => Ok(false),
333+
Err(err) => Err(IoError::Other(
334+
std::io::Error::from(err),
335+
IoOperation::Select,
336+
)),
337+
}
325338
}
326339
#[instrument(skip(self, buf), ret)]
327340
fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(usize, Option<SocketAddr>)> {

0 commit comments

Comments
 (0)