@@ -28,32 +28,34 @@ impl Client {
28
28
let io_ref = io. get_ref ( ) ;
29
29
let queue2 = queue. clone ( ) ;
30
30
ntex:: rt:: spawn ( async move {
31
- poll_fn ( |cx| match ready ! ( io. poll_read_next( & Codec , cx) ) {
32
- Some ( Ok ( item) ) => {
33
- if let Some ( tx) = queue2. borrow_mut ( ) . pop_front ( ) {
34
- let _ = tx. send ( Ok ( item) ) ;
35
- } else {
36
- log:: error!( "Unexpected redis response: {:?}" , item) ;
31
+ poll_fn ( |cx| loop {
32
+ match ready ! ( io. poll_read_next( & Codec , cx) ) {
33
+ Some ( Ok ( item) ) => {
34
+ if let Some ( tx) = queue2. borrow_mut ( ) . pop_front ( ) {
35
+ let _ = tx. send ( Ok ( item) ) ;
36
+ } else {
37
+ log:: error!( "Unexpected redis response: {:?}" , item) ;
38
+ }
39
+ continue ;
37
40
}
38
- Poll :: Pending
39
- }
40
- Some ( Err ( Either :: Left ( e) ) ) => {
41
- if let Some ( tx) = queue2. borrow_mut ( ) . pop_front ( ) {
42
- let _ = tx. send ( Err ( e) ) ;
41
+ Some ( Err ( Either :: Left ( e) ) ) => {
42
+ if let Some ( tx) = queue2. borrow_mut ( ) . pop_front ( ) {
43
+ let _ = tx. send ( Err ( e) ) ;
44
+ }
45
+ queue2. borrow_mut ( ) . clear ( ) ;
46
+ let _ = ready ! ( io. poll_shutdown( cx) ) ;
47
+ return Poll :: Ready ( ( ) ) ;
43
48
}
44
- queue2 . borrow_mut ( ) . clear ( ) ;
45
- let _ = ready ! ( io . poll_shutdown ( cx ) ) ;
46
- return Poll :: Ready ( ( ) ) ;
47
- }
48
- Some ( Err ( Either :: Right ( e ) ) ) => {
49
- if let Some ( tx ) = queue2 . borrow_mut ( ) . pop_front ( ) {
50
- let _ = tx . send ( Err ( e . into ( ) ) ) ;
49
+ Some ( Err ( Either :: Right ( e ) ) ) => {
50
+ if let Some ( tx ) = queue2 . borrow_mut ( ) . pop_front ( ) {
51
+ let _ = tx . send ( Err ( e . into ( ) ) ) ;
52
+ }
53
+ queue2 . borrow_mut ( ) . clear ( ) ;
54
+ let _ = ready ! ( io . poll_shutdown ( cx ) ) ;
55
+ return Poll :: Ready ( ( ) ) ;
51
56
}
52
- queue2. borrow_mut ( ) . clear ( ) ;
53
- let _ = ready ! ( io. poll_shutdown( cx) ) ;
54
- return Poll :: Ready ( ( ) ) ;
57
+ None => return Poll :: Ready ( ( ) ) ,
55
58
}
56
- None => Poll :: Ready ( ( ) ) ,
57
59
} )
58
60
. await
59
61
} ) ;
0 commit comments