@@ -384,28 +384,33 @@ impl NetworkBehaviour for Behaviour {
384384 loop {
385385 match self . state {
386386 GatewayState :: Searching ( ref mut fut) => match Pin :: new ( fut) . poll ( cx) {
387- Poll :: Ready ( result) => {
388- match result. expect ( "sender shouldn't have been dropped" ) {
389- Ok ( gateway) => {
390- if !is_addr_global ( gateway. external_addr ) {
391- self . state =
392- GatewayState :: NonRoutableGateway ( gateway. external_addr ) ;
393- tracing:: debug!(
394- gateway_address=%gateway. external_addr,
395- "the gateway is not routable"
396- ) ;
397- return Poll :: Ready ( ToSwarm :: GenerateEvent (
398- Event :: NonRoutableGateway ,
399- ) ) ;
400- }
401- self . state = GatewayState :: Available ( gateway) ;
402- }
403- Err ( err) => {
404- tracing:: debug!( "could not find gateway: {err}" ) ;
405- self . state = GatewayState :: GatewayNotFound ;
406- return Poll :: Ready ( ToSwarm :: GenerateEvent ( Event :: GatewayNotFound ) ) ;
387+ Poll :: Ready ( Ok ( result) ) => match result {
388+ Ok ( gateway) => {
389+ if !is_addr_global ( gateway. external_addr ) {
390+ self . state =
391+ GatewayState :: NonRoutableGateway ( gateway. external_addr ) ;
392+ tracing:: debug!(
393+ gateway_address=%gateway. external_addr,
394+ "the gateway is not routable"
395+ ) ;
396+ return Poll :: Ready ( ToSwarm :: GenerateEvent (
397+ Event :: NonRoutableGateway ,
398+ ) ) ;
407399 }
400+ self . state = GatewayState :: Available ( gateway) ;
401+ }
402+ Err ( err) => {
403+ tracing:: debug!( "could not find gateway: {err}" ) ;
404+ self . state = GatewayState :: GatewayNotFound ;
405+ return Poll :: Ready ( ToSwarm :: GenerateEvent ( Event :: GatewayNotFound ) ) ;
408406 }
407+ } ,
408+ Poll :: Ready ( Err ( err) ) => {
409+ // The sender channel has been dropped. This typically indicates a shutdown
410+ // process is underway.
411+ tracing:: debug!( "sender has been dropped: {err}" ) ;
412+ self . state = GatewayState :: GatewayNotFound ;
413+ return Poll :: Ready ( ToSwarm :: GenerateEvent ( Event :: GatewayNotFound ) ) ;
409414 }
410415 Poll :: Pending => return Poll :: Pending ,
411416 } ,
0 commit comments