debug command crash fix

This commit is contained in:
Christien Rioux 2024-05-18 01:02:50 -04:00
parent 2bb43cebaf
commit 25d804f11a
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();
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" {