Skip to content

Commit 32bf949

Browse files
committed
Propagate phy::RawSocket send error to caller
1 parent 61639d5 commit 32bf949

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/phy/raw_socket.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ impl phy::TxToken for TxToken {
111111
let mut lower = self.lower.borrow_mut();
112112
let mut buffer = vec![0; len];
113113
let result = f(&mut buffer);
114-
lower.send(&buffer[..]).unwrap();
114+
if let Err(err) = lower.send(&buffer[..]) {
115+
return match err.kind() {
116+
io::ErrorKind::WouldBlock => Err(crate::Error::Exhausted),
117+
_ => Err(crate::Error::Illegal),
118+
};
119+
}
115120
result
116121
}
117122
}

src/phy/sys/raw_socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl RawSocketDesc {
104104
0,
105105
);
106106
if len == -1 {
107-
Err(io::Error::last_os_error()).unwrap()
107+
return Err(io::Error::last_os_error());
108108
}
109109
Ok(len as usize)
110110
}

0 commit comments

Comments
 (0)