nal: Fix infinite loop when TX buffer is full

* For example, if the PHY linkup is down, instead of looping until resumption of the linkup, a write operation now closes the socket for re-connection in the future
This commit is contained in:
Harry Ho 2021-03-16 10:25:23 +08:00
parent 6de19f43cc
commit 2eadb652ff
1 changed files with 6 additions and 0 deletions

View File

@ -247,6 +247,12 @@ where
}; };
match result { match result {
Ok(num_bytes) => { Ok(num_bytes) => {
// If the buffer is completely filled, close the socket and
// return an error
if num_bytes == 0 {
write_error = true;
break;
}
// In case the buffer is filled up, push bytes into ethernet driver // In case the buffer is filled up, push bytes into ethernet driver
if num_bytes != non_queued_bytes.len() { if num_bytes != non_queued_bytes.len() {
self.update()?; self.update()?;