net/tcp: fix flush() waiting forever if socket is reset with pending write data

This commit is contained in:
Samuel Hicks 2024-07-19 17:45:29 +01:00
parent 2766993099
commit e6f4db507d

View File

@ -515,7 +515,7 @@ impl<'d> TcpIo<'d> {
async fn flush(&mut self) -> Result<(), Error> {
poll_fn(move |cx| {
self.with_mut(|s, _| {
let data_pending = s.send_queue() > 0;
let data_pending = (s.send_queue() > 0) && s.state() != tcp::State::Closed;
let fin_pending = matches!(
s.state(),
tcp::State::FinWait1 | tcp::State::Closing | tcp::State::LastAck