mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 00:21:08 +01:00
add poll_flush after a non blocked write to h1 dispatcher (#1971)
This commit is contained in:
parent
519d7f2b8a
commit
a6ed4aee84
@ -286,15 +286,12 @@ where
|
|||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
cx: &mut Context<'_>,
|
cx: &mut Context<'_>,
|
||||||
) -> Result<bool, DispatchError> {
|
) -> Result<bool, DispatchError> {
|
||||||
let len = self.write_buf.len();
|
|
||||||
if len == 0 {
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
let InnerDispatcherProj { io, write_buf, .. } = self.project();
|
let InnerDispatcherProj { io, write_buf, .. } = self.project();
|
||||||
let mut io = Pin::new(io.as_mut().unwrap());
|
let mut io = Pin::new(io.as_mut().unwrap());
|
||||||
|
|
||||||
|
let len = write_buf.len();
|
||||||
let mut written = 0;
|
let mut written = 0;
|
||||||
|
|
||||||
while written < len {
|
while written < len {
|
||||||
match io.as_mut().poll_write(cx, &write_buf[written..]) {
|
match io.as_mut().poll_write(cx, &write_buf[written..]) {
|
||||||
Poll::Ready(Ok(0)) => {
|
Poll::Ready(Ok(0)) => {
|
||||||
@ -314,9 +311,14 @@ where
|
|||||||
|
|
||||||
// SAFETY: setting length to 0 is safe
|
// SAFETY: setting length to 0 is safe
|
||||||
// skips one length check vs truncate
|
// skips one length check vs truncate
|
||||||
unsafe { write_buf.set_len(0) }
|
unsafe {
|
||||||
|
write_buf.set_len(0);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(false)
|
// flush the io and check if get blocked.
|
||||||
|
let blocked = io.poll_flush(cx)?.is_pending();
|
||||||
|
|
||||||
|
Ok(blocked)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_response(
|
fn send_response(
|
||||||
|
Loading…
Reference in New Issue
Block a user