diff --git a/zenoh/src/net/routing/hat/client/mod.rs b/zenoh/src/net/routing/hat/client/mod.rs index aa83c34f5d..419f55c81a 100644 --- a/zenoh/src/net/routing/hat/client/mod.rs +++ b/zenoh/src/net/routing/hat/client/mod.rs @@ -279,6 +279,9 @@ impl HatBaseTrait for HatCode { fn info(&self, _tables: &Tables, _kind: WhatAmI) -> String { "graph {}".to_string() } + + fn close(&self, _tables: &mut Tables) { + } } struct HatContext {} diff --git a/zenoh/src/net/routing/hat/linkstate_peer/mod.rs b/zenoh/src/net/routing/hat/linkstate_peer/mod.rs index a655d2f0a3..8aa9c69a39 100644 --- a/zenoh/src/net/routing/hat/linkstate_peer/mod.rs +++ b/zenoh/src/net/routing/hat/linkstate_peer/mod.rs @@ -451,6 +451,12 @@ impl HatBaseTrait for HatCode { _ => "graph {}".to_string(), } } + + fn close(&self, tables: &mut Tables) { + hat_mut!(tables).peer_qabls.clear(); + hat_mut!(tables).peer_subs.clear(); + hat_mut!(tables).peers_net.take(); + } } struct HatContext { diff --git a/zenoh/src/net/routing/hat/mod.rs b/zenoh/src/net/routing/hat/mod.rs index 4fbf9c9e5d..19fce045f5 100644 --- a/zenoh/src/net/routing/hat/mod.rs +++ b/zenoh/src/net/routing/hat/mod.rs @@ -110,6 +110,7 @@ pub(crate) trait HatBaseTrait { ) -> ZResult<()>; fn close_face(&self, tables: &TablesLock, face: &mut Arc); + fn close(&self, tables: &mut Tables); } pub(crate) trait HatPubSubTrait { diff --git a/zenoh/src/net/routing/hat/p2p_peer/mod.rs b/zenoh/src/net/routing/hat/p2p_peer/mod.rs index 8dc4f15ada..87f8bc6a2e 100644 --- a/zenoh/src/net/routing/hat/p2p_peer/mod.rs +++ b/zenoh/src/net/routing/hat/p2p_peer/mod.rs @@ -352,6 +352,10 @@ impl HatBaseTrait for HatCode { fn info(&self, _tables: &Tables, _kind: WhatAmI) -> String { "graph {}".to_string() } + + fn close(&self, tables: &mut Tables) { + hat_mut!(tables).gossip.take(); + } } struct HatContext {} diff --git a/zenoh/src/net/routing/hat/router/mod.rs b/zenoh/src/net/routing/hat/router/mod.rs index 24c837e8f5..7df245fa45 100644 --- a/zenoh/src/net/routing/hat/router/mod.rs +++ b/zenoh/src/net/routing/hat/router/mod.rs @@ -751,6 +751,15 @@ impl HatBaseTrait for HatCode { _ => "graph {}".to_string(), } } + + fn close(&self, tables: &mut Tables) { + hat_mut!(tables).peer_qabls.clear(); + hat_mut!(tables).router_qabls.clear(); + hat_mut!(tables).peer_subs.clear(); + hat_mut!(tables).router_subs.clear(); + hat_mut!(tables).peers_net.take(); + hat_mut!(tables).routers_net.take(); + } } struct HatContext { diff --git a/zenoh/src/net/runtime/mod.rs b/zenoh/src/net/runtime/mod.rs index 31edc1f603..45361fa3a6 100644 --- a/zenoh/src/net/runtime/mod.rs +++ b/zenoh/src/net/runtime/mod.rs @@ -24,7 +24,7 @@ use super::primitives::DeMux; use super::routing; use super::routing::router::Router; use crate::config::{unwrap_or_default, Config, ModeDependent, Notifier}; -use crate::net::routing::resource::Resource; +use crate::net::routing::dispatcher::resource::Resource; use crate::GIT_VERSION; pub use adminspace::AdminSpace; use async_std::task::JoinHandle; @@ -173,7 +173,10 @@ impl Runtime { // clean up to break cyclic reference of self.state to itself let router = self.router(); let mut tables = router.tables.tables.write().unwrap(); + Resource::close(&mut tables.root_res); + let hat_code = tables.hat_code.clone(); + hat_code.close(&mut tables); drop(tables); self.state.transport_handlers.write().unwrap().clear();