File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -418,19 +418,31 @@ impl ProtocolSet {
418418 } )
419419 . collect :: < FuturesUnordered < _ > > ( ) ;
420420
421+ // Capture the first error that occurs while reporting to protocols.
422+ let mut protocol_error = None ;
421423 while !futures. is_empty ( ) {
422- if let Some ( Err ( error) ) = futures. next ( ) . await {
423- return Err ( error. into ( ) ) ;
424+ if let Some ( Err ( err) ) = futures. next ( ) . await {
425+ if protocol_error. is_none ( ) {
426+ protocol_error = Some ( err. into ( ) ) ;
427+ }
424428 }
425429 }
426430
431+ // Ensure the manager receives the connection closed event. Otherwise, the
432+ // manager will think the connection is still open, while the underlying
433+ // protocols and raw connection are closed.
427434 self . mgr_tx
428435 . send ( TransportManagerEvent :: ConnectionClosed {
429436 peer,
430437 connection : connection_id,
431438 } )
432- . await
433- . map_err ( From :: from)
439+ . await ?;
440+
441+ // If any protocol report failed, return that error now
442+ match protocol_error {
443+ Some ( e) => Err ( e) ,
444+ None => Ok ( ( ) ) ,
445+ }
434446 }
435447}
436448
You can’t perform that action at this time.
0 commit comments