fix sending unpublish event

This commit is contained in:
Christien Rioux 2025-06-15 19:38:20 -04:00
parent 808cbda229
commit ee1e2b436f
5 changed files with 23 additions and 5 deletions

View file

@ -275,7 +275,7 @@ impl RoutingTableInner {
} }
/// Unpublish the node's current peer info /// Unpublish the node's current peer info
pub fn unpublish_peer_info(&mut self, routing_domain: RoutingDomain) { pub fn unpublish_peer_info(&mut self, routing_domain: RoutingDomain) {
self.with_routing_domain(routing_domain, |rdd| rdd.unpublish_peer_info()) self.with_routing_domain(routing_domain, |rdd| rdd.unpublish_peer_info(self))
} }
/// Get the current published peer info /// Get the current published peer info

View file

@ -191,10 +191,19 @@ impl RoutingDomainDetail for LocalNetworkRoutingDomainDetail {
true true
} }
fn unpublish_peer_info(&self) { fn unpublish_peer_info(&self, rti: &RoutingTableInner) {
let mut ppi_lock = self.published_peer_info.lock(); let mut ppi_lock = self.published_peer_info.lock();
veilid_log!(self debug "[LocalNetwork] Unpublished peer info"); veilid_log!(self debug "[LocalNetwork] Unpublished peer info");
let opt_old_peer_info = ppi_lock.clone();
*ppi_lock = None; *ppi_lock = None;
if let Err(e) = rti.event_bus().post(PeerInfoChangeEvent {
routing_domain: RoutingDomain::LocalNetwork,
opt_old_peer_info,
opt_new_peer_info: None,
}) {
veilid_log!(self debug "Failed to post event: {}", e);
}
} }
fn ensure_dial_info_is_valid(&self, dial_info: &DialInfo) -> bool { fn ensure_dial_info_is_valid(&self, dial_info: &DialInfo) -> bool {

View file

@ -40,7 +40,7 @@ pub trait RoutingDomainDetail {
// Publish current peer info to the world // Publish current peer info to the world
fn publish_peer_info(&self, rti: &RoutingTableInner) -> bool; fn publish_peer_info(&self, rti: &RoutingTableInner) -> bool;
fn unpublish_peer_info(&self); fn unpublish_peer_info(&self, rti: &RoutingTableInner);
// Get the contact method required for node A to reach node B in this routing domain // Get the contact method required for node A to reach node B in this routing domain
// Routing table must be locked for reading to use this function // Routing table must be locked for reading to use this function

View file

@ -170,10 +170,19 @@ impl RoutingDomainDetail for PublicInternetRoutingDomainDetail {
true true
} }
fn unpublish_peer_info(&self) { fn unpublish_peer_info(&self, rti: &RoutingTableInner) {
let mut ppi_lock = self.published_peer_info.lock(); let mut ppi_lock = self.published_peer_info.lock();
veilid_log!(self debug "[PublicInternet] Unpublished peer info"); veilid_log!(self debug "[PublicInternet] Unpublished peer info");
let opt_old_peer_info = ppi_lock.clone();
*ppi_lock = None; *ppi_lock = None;
if let Err(e) = rti.event_bus().post(PeerInfoChangeEvent {
routing_domain: RoutingDomain::PublicInternet,
opt_old_peer_info,
opt_new_peer_info: None,
}) {
veilid_log!(self debug "Failed to post event: {}", e);
}
} }
fn ensure_dial_info_is_valid(&self, dial_info: &DialInfo) -> bool { fn ensure_dial_info_is_valid(&self, dial_info: &DialInfo) -> bool {

View file

@ -347,7 +347,7 @@ impl RoutingTable {
let atomic_count = AtomicUsize::new(count); let atomic_count = AtomicUsize::new(count);
let _ = process_batched_future_queue_result(future_queue, MAX_PARALLEL_PINGS, stop_token, |res| { let _ = process_batched_future_queue_result(future_queue, MAX_PARALLEL_PINGS, stop_token, |res| {
if let Err(e) = res { if let Err(e) = res {
veilid_log!(self error "[{}] Error performing status ping: {}", name, e); veilid_log!(self debug "[{}] Error performing status ping: {}", name, e);
} }
let remaining = atomic_count.fetch_sub(1, Ordering::AcqRel) - 1; let remaining = atomic_count.fetch_sub(1, Ordering::AcqRel) - 1;
if remaining > 0 { if remaining > 0 {