File tree Expand file tree Collapse file tree 2 files changed +42
-7
lines changed
async-ssh2-lite/src/session_stream Expand file tree Collapse file tree 2 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,10 @@ use std::io::{Error as IoError, ErrorKind as IoErrorKind};
66
77use async_io:: { Async , Timer } ;
88use async_trait:: async_trait;
9- use futures_util:: { future, pin_mut, ready} ;
9+ use futures_util:: {
10+ future:: { self , Either } ,
11+ pin_mut, ready,
12+ } ;
1013use ssh2:: { BlockDirections , Error as Ssh2Error , Session } ;
1114
1215use super :: { AsyncSessionStream , BlockDirectionsExt as _} ;
@@ -53,10 +56,14 @@ where
5356 assert ! ( expected_block_directions. is_readable( ) ) ;
5457 assert ! ( expected_block_directions. is_writable( ) ) ;
5558
56- let ( ret, _ ) = future:: select ( self . readable ( ) , self . writable ( ) )
59+ let ( ret, either ) = future:: select ( self . readable ( ) , self . writable ( ) )
5760 . await
5861 . factor_first ( ) ;
59- ret?
62+ ret?;
63+ match either {
64+ Either :: Left ( _) => self . writable ( ) . await ?,
65+ Either :: Right ( _) => self . readable ( ) . await ?,
66+ }
6067 }
6168 }
6269
Original file line number Diff line number Diff line change @@ -52,8 +52,22 @@ impl AsyncSessionStream for TcpStream {
5252 assert ! ( expected_block_directions. is_readable( ) ) ;
5353 assert ! ( expected_block_directions. is_writable( ) ) ;
5454
55- self . ready ( tokio:: io:: Interest :: READABLE | tokio:: io:: Interest :: WRITABLE )
56- . await ?;
55+ loop {
56+ let ready = self
57+ . ready ( tokio:: io:: Interest :: READABLE | tokio:: io:: Interest :: WRITABLE )
58+ . await ?;
59+ if ready. is_readable ( ) {
60+ self . writable ( ) . await ?;
61+ break ;
62+ } else if ready. is_writable ( ) {
63+ self . readable ( ) . await ?;
64+ break ;
65+ } else if ready. is_empty ( ) {
66+ continue ;
67+ } else {
68+ break ;
69+ }
70+ }
5771 }
5872 }
5973
@@ -152,8 +166,22 @@ impl AsyncSessionStream for UnixStream {
152166 assert ! ( expected_block_directions. is_readable( ) ) ;
153167 assert ! ( expected_block_directions. is_writable( ) ) ;
154168
155- self . ready ( tokio:: io:: Interest :: READABLE | tokio:: io:: Interest :: WRITABLE )
156- . await ?;
169+ loop {
170+ let ready = self
171+ . ready ( tokio:: io:: Interest :: READABLE | tokio:: io:: Interest :: WRITABLE )
172+ . await ?;
173+ if ready. is_readable ( ) {
174+ self . writable ( ) . await ?;
175+ break ;
176+ } else if ready. is_writable ( ) {
177+ self . readable ( ) . await ?;
178+ break ;
179+ } else if ready. is_empty ( ) {
180+ continue ;
181+ } else {
182+ break ;
183+ }
184+ }
157185 }
158186 }
159187
You can’t perform that action at this time.
0 commit comments