Queue wakeup in all cases when we write to our internal buffer

This commit is contained in:
asonix 2023-07-16 15:16:11 -05:00
parent 5bb45e9e82
commit b655ef8511
2 changed files with 7 additions and 0 deletions

View file

@ -12,6 +12,7 @@ mime = "0.3"
rand = { version = "0.8", features = ["small_rng"] }
tokio = { version = "1", default-features = false, features = [ "io-util" ] }
tokio-util = { version = "0.7", default-features = false, features = ["io"] }
tracing = "0.1.37"
[dev-dependencies]
common-multipart-rfc7578 = "0.6.0"

View file

@ -192,6 +192,7 @@ where
}
if self.closed {
tracing::debug!("Polled for close");
return Poll::Ready(Ok(()));
}
@ -203,6 +204,7 @@ where
if crlf_len() < buf.remaining() {
write_crlf(buf);
} else {
cx.waker().wake_by_ref();
self.write_clrf_to_pending();
}
@ -218,6 +220,7 @@ where
if keep_writing && boundary_len(&self.boundary) < buf.remaining() {
write_boundary(&self.boundary, buf);
} else {
cx.waker().wake_by_ref();
self.write_boundary_to_pending();
keep_writing = false;
};
@ -225,6 +228,7 @@ where
if keep_writing && headers_len(&part) < buf.remaining() {
write_headers(&part, buf);
} else {
cx.waker().wake_by_ref();
self.write_headers_to_pending(&part);
};
@ -239,11 +243,13 @@ where
if buf.remaining() > crlf_len() {
write_crlf(buf);
} else {
cx.waker().wake_by_ref();
self.write_clrf_to_pending();
}
poll_return(buf.filled().len() > initial_len)
} else {
self.closed = true;
cx.waker().wake_by_ref();
self.write_final_boundary_to_pending();
self.write_clrf_to_pending();
poll_return(buf.filled().len() > initial_len)