@@ -467,9 +467,10 @@ impl RemoteStateActor {
467467 path. set_status ( status) . ok ( ) ;
468468 conn_state. add_open_path ( path_remote. clone ( ) , PathId :: ZERO ) ;
469469 self . paths
470- . insert ( path_remote, Source :: Connection { _0 : Private } ) ;
470+ . insert ( path_remote. clone ( ) , Source :: Connection { _0 : Private } ) ;
471+ self . paths . opened_path ( & path_remote) ;
471472 self . select_path ( ) ;
472- self . prune_ip_paths ( ) ;
473+ self . prune_paths ( ) ;
473474
474475 if path_remote_is_ip {
475476 // We may have raced this with a relay address. Try and add any
@@ -506,6 +507,7 @@ impl RemoteStateActor {
506507 self . paths . resolve_remote ( tx) ;
507508 // Start discovery if we have no selected path.
508509 self . trigger_discovery ( ) ;
510+ self . prune_paths ( ) ;
509511 }
510512
511513 /// Handles [`RemoteStateMessage::Latency`].
@@ -552,6 +554,7 @@ impl RemoteStateActor {
552554 let addrs =
553555 to_transports_addr ( self . endpoint_id , item. into_endpoint_addr ( ) . addrs ) ;
554556 self . paths . insert_multiple ( addrs, source) ;
557+ self . prune_paths ( ) ;
555558 }
556559 }
557560 }
@@ -804,16 +807,18 @@ impl RemoteStateActor {
804807 conn_state. add_open_path ( path_remote. clone ( ) , path_id) ;
805808 self . paths
806809 . insert ( path_remote. clone ( ) , Source :: Connection { _0 : Private } ) ;
807- self . paths . holepunched ( & path_remote) ;
810+ self . paths . opened_path ( & path_remote) ;
808811 }
809812
810813 self . select_path ( ) ;
811- self . prune_ip_paths ( ) ;
814+ self . prune_paths ( ) ;
812815 }
813816 PathEvent :: Abandoned { id, path_stats } => {
814817 trace ! ( ?path_stats, "path abandoned" ) ;
815818 // This is the last event for this path.
816- conn_state. remove_path ( & id) ;
819+ if let Some ( addr) = conn_state. remove_path ( & id) {
820+ self . paths . abandoned_path ( & addr) ;
821+ }
817822 }
818823 PathEvent :: Closed { id, .. } | PathEvent :: LocallyClosed { id, .. } => {
819824 let Some ( path_remote) = conn_state. paths . get ( & id) . cloned ( ) else {
@@ -963,16 +968,8 @@ impl RemoteStateActor {
963968
964969 /// TODO: fix up docs once review indicates this is actually
965970 /// the criteria for pruning.
966- fn prune_ip_paths ( & mut self ) {
967- let open_paths = self
968- . connections
969- . values ( )
970- . flat_map ( |state| state. open_paths . values ( ) ) ;
971- self . paths . prune_ip_paths (
972- & self . pending_open_paths ,
973- & self . selected_path . get ( ) ,
974- open_paths,
975- ) ;
971+ fn prune_paths ( & mut self ) {
972+ self . paths . prune_paths ( ) ;
976973 }
977974}
978975
@@ -1093,11 +1090,13 @@ impl ConnectionState {
10931090 }
10941091
10951092 /// Completely removes a path from this connection.
1096- fn remove_path ( & mut self , path_id : & PathId ) {
1097- if let Some ( addr) = self . paths . remove ( path_id) {
1098- self . path_ids . remove ( & addr) ;
1093+ fn remove_path ( & mut self , path_id : & PathId ) -> Option < transports:: Addr > {
1094+ let addr = self . paths . remove ( path_id) ;
1095+ if let Some ( ref addr) = addr {
1096+ self . path_ids . remove ( addr) ;
10991097 }
11001098 self . open_paths . remove ( path_id) ;
1099+ addr
11011100 }
11021101
11031102 /// Removes the path from the open paths.
0 commit comments