File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ impl Decoder for MuxCodec {
95
95
type Error = MuxError ;
96
96
97
97
fn decode ( & mut self , src : & mut BytesMut ) -> Result < Option < Self :: Item > , Self :: Error > {
98
+ src. reserve ( HEADER_SIZE + MAX_PAYLOAD_SIZE + HEADER_SIZE ) ;
99
+
98
100
if src. len ( ) < HEADER_SIZE {
99
101
return Ok ( None ) ;
100
102
}
Original file line number Diff line number Diff line change @@ -317,4 +317,29 @@ mod tests {
317
317
318
318
assert ! ( stream2. write_all( b"1234" ) . await . is_err( ) ) ;
319
319
}
320
+
321
+ #[ tokio:: test]
322
+ async fn test_inner_shutdown ( ) {
323
+ let ( a, b) = get_tcp_pair ( ) . await ;
324
+
325
+ let ( connector_a, mut acceptor_a, worker_a) =
326
+ MuxBuilder :: client ( ) . with_connection ( a) . build ( ) ;
327
+ let ( connector_b, mut acceptor_b, worker_b) =
328
+ MuxBuilder :: server ( ) . with_connection ( b) . build ( ) ;
329
+
330
+ let a_res = tokio:: spawn ( worker_a) ;
331
+ drop ( worker_b) ;
332
+ tokio:: time:: sleep ( Duration :: from_secs ( 2 ) ) . await ;
333
+
334
+ assert ! ( connector_b. connect( ) . is_err( ) ) ;
335
+ assert ! ( acceptor_b. accept( ) . await . is_none( ) ) ;
336
+
337
+ drop ( connector_b) ;
338
+ drop ( acceptor_b) ;
339
+
340
+ tokio:: time:: sleep ( Duration :: from_secs ( 2 ) ) . await ;
341
+ assert ! ( connector_a. connect( ) . is_err( ) ) ;
342
+ assert ! ( acceptor_a. accept( ) . await . is_none( ) ) ;
343
+ a_res. await . unwrap ( ) . unwrap_err ( ) ;
344
+ }
320
345
}
Original file line number Diff line number Diff line change @@ -626,10 +626,7 @@ impl<T: TokioConn> MuxState<T> {
626
626
self . check_closed ( ) ?;
627
627
628
628
if let Some ( r) = ready ! ( self . inner. poll_next_unpin( cx) ) {
629
- let frame = r. map_err ( |e| {
630
- self . close ( ) ;
631
- e
632
- } ) ?;
629
+ let frame = r. inspect_err ( |_| self . close ( ) ) ?;
633
630
Poll :: Ready ( Ok ( frame) )
634
631
} else {
635
632
self . close ( ) ;
You can’t perform that action at this time.
0 commit comments