debug command crash fix

This commit is contained in:
Christien Rioux 2024-05-18 01:02:50 -04:00 committed by k8wu
parent 426b25917b
commit 38f4ff66de
2 changed files with 16 additions and 3 deletions

View File

@ -340,6 +340,14 @@ impl NetworkManager {
.connection_manager
.clone()
}
pub fn opt_connection_manager(&self) -> Option<ConnectionManager> {
self.unlocked_inner
.components
.read()
.as_ref()
.map(|x| x.connection_manager.clone())
}
pub fn update_callback(&self) -> UpdateCallback {
self.unlocked_inner
.update_callback

View File

@ -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();
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();
if let Some(connection_manager) = &opt_connection_manager {
connection_manager.startup().await;
}
Ok("Connections purged".to_owned())
} else if args[0] == "routes" {