diff --git a/veilid-core/src/network_manager/mod.rs b/veilid-core/src/network_manager/mod.rs index 04d95278..66d200af 100644 --- a/veilid-core/src/network_manager/mod.rs +++ b/veilid-core/src/network_manager/mod.rs @@ -340,6 +340,14 @@ impl NetworkManager { .connection_manager .clone() } + pub fn opt_connection_manager(&self) -> Option { + self.unlocked_inner + .components + .read() + .as_ref() + .map(|x| x.connection_manager.clone()) + } + pub fn update_callback(&self) -> UpdateCallback { self.unlocked_inner .update_callback diff --git a/veilid-core/src/veilid_api/debug.rs b/veilid-core/src/veilid_api/debug.rs index 8c7674c5..287af751 100644 --- a/veilid-core/src/veilid_api/debug.rs +++ b/veilid-core/src/veilid_api/debug.rs @@ -853,15 +853,20 @@ impl VeilidAPI { Ok("Buckets purged".to_owned()) } else if args[0] == "connections" { // Purge connection table - let connection_manager = self.network_manager()?.connection_manager(); - connection_manager.shutdown().await; + let opt_connection_manager = self.network_manager()?.opt_connection_manager(); + + if let Some(connection_manager) = &opt_connection_manager { + connection_manager.shutdown().await; + } // Eliminate last_connections from routing table entries self.network_manager()? .routing_table() .purge_last_connections(); - connection_manager.startup().await; + if let Some(connection_manager) = &opt_connection_manager { + connection_manager.startup().await; + } Ok("Connections purged".to_owned()) } else if args[0] == "routes" {