outbound/obfs: flush stream directly
This commit is contained in:
@@ -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<()>> {
|
||||
|
||||
@@ -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<()>> {
|
||||
|
||||
Reference in New Issue
Block a user