浏览代码

Changed behavior of phy::RawSocket TxToken::consume to be more similar to RawSocket::receive

Jade 3 年之前
父节点
当前提交
32974f8136
共有 1 个文件被更改,包括 4 次插入6 次删除
  1. 4 6
      src/phy/raw_socket.rs

+ 4 - 6
src/phy/raw_socket.rs

@@ -111,12 +111,10 @@ impl phy::TxToken for TxToken {
         let mut lower = self.lower.borrow_mut();
         let mut buffer = vec![0; len];
         let result = f(&mut buffer);
-        if let Err(err) = lower.send(&buffer[..]) {
-            return match err.kind() {
-                io::ErrorKind::WouldBlock => Err(crate::Error::Exhausted),
-                _ => Err(crate::Error::Illegal),
-            };
+        match lower.send(&buffer[..]) {
+            Ok(_) => result,
+            Err(err) if err.kind() == io::ErrorKind::WouldBlock => Err(crate::Error::Exhausted),
+            Err(err) => panic!("{}", err),
         }
-        result
     }
 }