From 2eadb652ff1d8e043736006aa74170dbb6d67f15 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Tue, 16 Mar 2021 10:25:23 +0800 Subject: [PATCH] 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 --- src/nal.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nal.rs b/src/nal.rs index 5d23898..5648faf 100644 --- a/src/nal.rs +++ b/src/nal.rs @@ -247,6 +247,12 @@ where }; match result { 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 if num_bytes != non_queued_bytes.len() { self.update()?;