diff --git a/veilid-core/src/network_manager/tasks/public_address_check.rs b/veilid-core/src/network_manager/tasks/public_address_check.rs index 4ba03b38..e62567a6 100644 --- a/veilid-core/src/network_manager/tasks/public_address_check.rs +++ b/veilid-core/src/network_manager/tasks/public_address_check.rs @@ -268,6 +268,11 @@ impl NetworkManager { if detect_address_changes { // Reset the address check cache now so we can start detecting fresh info!("Public address has changed, detecting public dial info"); + log_net!(debug "report_global_socket_address\nsocket_address: {:#?}\nflow: {:#?}\nreporting_peer: {:#?}", socket_address, flow, reporting_peer); + log_net!(debug + "public_address_check_cache: {:#?}", + inner.public_address_check_cache + ); inner.public_address_check_cache.clear(); diff --git a/veilid-core/src/storage_manager/mod.rs b/veilid-core/src/storage_manager/mod.rs index f4156d55..1f110bbd 100644 --- a/veilid-core/src/storage_manager/mod.rs +++ b/veilid-core/src/storage_manager/mod.rs @@ -139,14 +139,19 @@ impl StorageManager { pub async fn terminate(&self) { log_stor!(debug "starting storage manager shutdown"); - let mut inner = self.inner.lock().await; - inner.terminate().await; + { + let mut inner = self.inner.lock().await; + inner.terminate().await; + } // Cancel all tasks self.cancel_tasks().await; // Release the storage manager - *inner = Self::new_inner(self.unlocked_inner.clone()); + { + let mut inner = self.inner.lock().await; + *inner = Self::new_inner(self.unlocked_inner.clone()); + } log_stor!(debug "finished storage manager shutdown"); } diff --git a/veilid-core/src/storage_manager/tasks/offline_subkey_writes.rs b/veilid-core/src/storage_manager/tasks/offline_subkey_writes.rs index 164cf7ae..5c4eb8ce 100644 --- a/veilid-core/src/storage_manager/tasks/offline_subkey_writes.rs +++ b/veilid-core/src/storage_manager/tasks/offline_subkey_writes.rs @@ -10,18 +10,13 @@ impl StorageManager { _last_ts: Timestamp, _cur_ts: Timestamp, ) -> EyreResult<()> { - let (mut offline_subkey_writes, opt_update_callback) = { + let mut offline_subkey_writes = { let mut inner = self.lock().await?; - let out = ( - inner.offline_subkey_writes.clone(), - inner.update_callback.clone(), - ); + let out = inner.offline_subkey_writes.clone(); inner.offline_subkey_writes.clear(); out }; - let mut fanout_results = vec![]; - for (key, osw) in offline_subkey_writes.iter_mut() { if poll!(stop_token.clone()).is_ready() { log_stor!(debug "Offline subkey writes cancelled."); @@ -32,6 +27,8 @@ impl StorageManager { break; }; + let mut fanout_results = vec![]; + let mut written_subkeys = ValueSubkeyRangeSet::new(); for subkey in osw.subkeys.iter() { let get_result = { @@ -63,7 +60,7 @@ impl StorageManager { *key, subkey, osw.safety_selection, - value, + value.clone(), descriptor, ) .await; @@ -85,24 +82,23 @@ impl StorageManager { &result.fanout_result, ); if !was_offline { - if let Some(update_callback) = opt_update_callback.clone() { - // Send valuechange with dead count and no subkeys - update_callback(VeilidUpdate::ValueChange(Box::new( - VeilidValueChange { - key: *key, - subkeys: ValueSubkeyRangeSet::single(subkey), - count: u32::MAX, - value: Some( - result - .signed_value_data - .value_data() - .clone(), - ), - }, - ))); - } written_subkeys.insert(subkey); - }; + } + + // Set the new value if it differs from what was asked to set + if result.signed_value_data.value_data() != value.value_data() { + // Record the newer value and send and update since it is different than what we just set + let mut inner = self.lock().await?; + inner + .handle_set_local_value( + *key, + subkey, + result.signed_value_data.clone(), + WatchUpdateMode::UpdateAll, + ) + .await?; + } + fanout_results.push((subkey, result.fanout_result)); break; }