aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-net/src/tcp.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs
index c508ff97a..57c9b7a04 100644
--- a/embassy-net/src/tcp.rs
+++ b/embassy-net/src/tcp.rs
@@ -491,10 +491,16 @@ impl<'d> TcpIo<'d> {
491 async fn flush(&mut self) -> Result<(), Error> { 491 async fn flush(&mut self) -> Result<(), Error> {
492 poll_fn(move |cx| { 492 poll_fn(move |cx| {
493 self.with_mut(|s, _| { 493 self.with_mut(|s, _| {
494 let waiting_close = s.state() == tcp::State::Closed && s.remote_endpoint().is_some(); 494 let data_pending = s.send_queue() > 0;
495 let fin_pending = matches!(
496 s.state(),
497 tcp::State::FinWait1 | tcp::State::Closing | tcp::State::LastAck
498 );
499 let rst_pending = s.state() == tcp::State::Closed && s.remote_endpoint().is_some();
500
495 // If there are outstanding send operations, register for wake up and wait 501 // If there are outstanding send operations, register for wake up and wait
496 // smoltcp issues wake-ups when octets are dequeued from the send buffer 502 // smoltcp issues wake-ups when octets are dequeued from the send buffer
497 if s.send_queue() > 0 || waiting_close { 503 if data_pending || fin_pending || rst_pending {
498 s.register_send_waker(cx.waker()); 504 s.register_send_waker(cx.waker());
499 Poll::Pending 505 Poll::Pending
500 // No outstanding sends, socket is flushed 506 // No outstanding sends, socket is flushed