Skip to content

Commit

Permalink
fix(net): ignore EINTR errno response from select (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiapple852 committed Sep 2, 2023
1 parent bc5a471 commit d53e5f0
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/tracing/net/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use nix::{
sys::select::FdSet,
sys::socket::{AddressFamily, SockaddrLike},
sys::time::{TimeVal, TimeValLike},
Error,
};
use socket2::{Domain, Protocol, SockAddr, Type};
use std::io;
Expand Down Expand Up @@ -305,9 +306,15 @@ impl TracerSocket for Socket {
None,
None,
Some(&mut TimeVal::milliseconds(timeout.as_millis() as i64)),
)
.map_err(|err| IoError::Other(std::io::Error::from(err), IoOperation::Select))?;
Ok(readable == 1)
);
match readable {
Ok(readable) => Ok(readable == 1),
Err(err) if err == Error::EINTR => Ok(false),
Err(err) => Err(IoError::Other(
std::io::Error::from(err),
IoOperation::Select,
)),
}
}
#[instrument(skip(self))]
fn is_writable(&self) -> IoResult<bool> {
Expand All @@ -319,9 +326,15 @@ impl TracerSocket for Socket {
Some(&mut write),
None,
Some(&mut TimeVal::zero()),
)
.map_err(|err| IoError::Other(std::io::Error::from(err), IoOperation::Select))?;
Ok(writable == 1)
);
match writable {
Ok(writable) => Ok(writable == 1),
Err(err) if err == Error::EINTR => Ok(false),
Err(err) => Err(IoError::Other(
std::io::Error::from(err),
IoOperation::Select,
)),
}
}
#[instrument(skip(self, buf), ret)]
fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(usize, Option<SocketAddr>)> {
Expand Down

0 comments on commit d53e5f0

Please sign in to comment.