Merge pull request #3198 from sammhicks/main

net/tcp: fix flush() waiting forever if socket is reset with pending write data
This commit is contained in:
Dario Nieuwenhuis 2024-08-13 17:45:09 +00:00 committed by GitHub
commit 7a26e117cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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