File tree Expand file tree Collapse file tree 1 file changed +21
-14
lines changed Expand file tree Collapse file tree 1 file changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -912,25 +912,32 @@ impl<H: Handler> Future for Flush<H> {
912
912
913
913
fn poll ( & mut self ) -> Poll < Self :: Item , Self :: Error > {
914
914
915
+ if let Some ( ref mut c) = self . connection {
916
+ c. state = Some ( ConnectionState :: Write )
917
+ }
915
918
loop {
916
919
debug ! ( "flush loop" ) ;
917
- let completely_written = if let Some ( ref mut c) = self . connection {
918
- if let Some ( ref mut s) = c. session {
919
- try!( s. flush ( ) ) ;
920
- try_nb ! ( s. 0 . write_buffer. write_all( c. stream. get_mut( ) ) )
921
- } else {
922
- unreachable ! ( )
920
+ if let Some ( mut c) = self . connection . take ( ) {
921
+ match try!( c. atomic_poll ( ) ) {
922
+ Async :: Ready ( false ) => return Ok ( Async :: Ready ( c) ) ,
923
+ Async :: NotReady => {
924
+ self . connection = Some ( c) ;
925
+ return Ok ( Async :: NotReady )
926
+ } ,
927
+ Async :: Ready ( true ) => {
928
+ match c. state {
929
+ Some ( ConnectionState :: Write ) |
930
+ Some ( ConnectionState :: Flush ) => {
931
+ self . connection = Some ( c) ;
932
+ } ,
933
+ _ => {
934
+ return Ok ( Async :: Ready ( c) )
935
+ }
936
+ }
937
+ }
923
938
}
924
939
} else {
925
940
unreachable ! ( )
926
- } ;
927
- if completely_written {
928
- if let Some ( mut c) = self . connection . take ( ) {
929
- c. state = Some ( ConnectionState :: Write ) ;
930
- return Ok ( Async :: Ready ( c) ) ;
931
- } else {
932
- unreachable ! ( )
933
- }
934
941
}
935
942
}
936
943
}
You can’t perform that action at this time.
0 commit comments