File tree Expand file tree Collapse file tree
iroh-net/src/hp/magicsock Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -360,15 +360,21 @@ impl DerpActor {
360360 reader : ReaderState :: new ( region_id, cancel, dc. clone ( ) ) ,
361361 } ;
362362
363- // Make sure we can establish a connection.
364- if let Err ( err) = dc. connect ( ) . await {
365- // TODO: what to do?
366- warn ! ( "failed to connect to derp server: {:?}" , err) ;
367- }
368-
363+ // Insert, to make sure we do not attempt to double connect.
369364 self . active_derp . insert ( region_id, ad) ;
370365
366+ // Kickoff a connection establishment in the background
367+ let dc_spawn = dc. clone ( ) ;
368+ tokio:: task:: spawn ( async move {
369+ // Make sure we can establish a connection.
370+ if let Err ( err) = dc_spawn. connect ( ) . await {
371+ // TODO: what to do?
372+ warn ! ( "failed to connect to derp server: {:?}" , err) ;
373+ }
374+ } ) ;
375+
371376 inc ! ( MagicsockMetrics , num_derp_conns_added) ;
377+
372378 self . log_active_derp ( ) ;
373379
374380 if let Some ( ref f) = self . conn . on_derp_active {
You can’t perform that action at this time.
0 commit comments