Bug 1768090 - Ignore error from UDP soocket. r=necko-reviewers,kershaw

A UDP socket may receive a ConnecionReset error if a packet is sent to an unreachable port. This is not a reason to close the soccket.

Differential Revision: https://phabricator.services.mozilla.com/D146951
This commit is contained in:
Dragana Damjanovic 2022-05-24 04:19:20 +00:00
Родитель 5f8ec0cf29
Коммит 6aad873dae
1 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -446,15 +446,15 @@ fn read_dgram(
local_address: &SocketAddr,
) -> Result<Option<Datagram>, io::Error> {
let buf = &mut [0u8; 2048];
let (sz, remote_addr) = match socket.recv_from(&mut buf[..]) {
Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => return Ok(None),
Err(err) => {
let res = socket.recv_from(&mut buf[..]);
if let Some(err) = res.as_ref().err() {
if err.kind() != io::ErrorKind::WouldBlock {
eprintln!("UDP recv error: {:?}", err);
return Err(err);
}
Ok(res) => res,
return Ok(None);
};
let (sz, remote_addr) = res.unwrap();
if sz == buf.len() {
eprintln!("Might have received more than {} bytes", buf.len());
}