outbound/obfs: flush stream directly

This commit is contained in:
bdbai
2023-03-29 15:24:34 +08:00
committed by eycorsican
parent 7d61235517
commit 442d684978
2 changed files with 2 additions and 36 deletions

View File

@@ -167,24 +167,7 @@ impl AsyncWrite for Stream {
}
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
let Self {
write_state,
stream,
..
} = &mut *self;
loop {
match write_state {
WriteState::Initial { .. } => return Poll::Ready(Ok(())),
WriteState::WritingRequest(req) => {
ready!(poll_write_buf(Pin::new(stream), cx, req))?;
if req.position() as usize == req.get_ref().len() {
*write_state = WriteState::Transfer;
}
}
WriteState::Transfer => break,
}
}
Pin::new(&mut *stream).poll_flush(cx)
Pin::new(&mut self.stream).poll_flush(cx)
}
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {

View File

@@ -248,24 +248,7 @@ impl AsyncWrite for Stream {
}
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
let Self {
stream,
write_state,
..
} = &mut *self;
loop {
match write_state {
WriteState::Initial { .. } => return Poll::Ready(Ok(())),
WriteState::WritingRequest(req) => {
ready!(poll_write_buf(Pin::new(stream), cx, req))?;
if req.position() as usize == req.get_ref().len() {
*write_state = WriteState::WritingPayload { chunk_remaining: 0 };
}
}
_ => break,
}
}
Pin::new(&mut *stream).poll_flush(cx)
Pin::new(&mut self.stream).poll_flush(cx)
}
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {