From ddd2c284f693954108371767a183b430b93a7b72 Mon Sep 17 00:00:00 2001 From: Thomas Karpiniec Date: Sat, 15 Jun 2024 12:36:03 +0100 Subject: [PATCH 1/1] Make Windows watcher fail if initial interface listing fails --- src/watch_win.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/watch_win.rs b/src/watch_win.rs index 23b274e..3a4a301 100644 --- a/src/watch_win.rs +++ b/src/watch_win.rs @@ -60,10 +60,8 @@ pub(crate) fn watch_interfaces( }; match res { NO_ERROR => { - // Trigger an initial update. - // This is allowed to race with true updates because it - // will always calculate a diff and discard no-ops. - handle_notif(&mut state.lock().unwrap()); + // Trigger an initial update + handle_notif(&mut state.lock().unwrap(), crate::list::list_interfaces()?); // Then return the handle Ok(WatchHandle { hnd, _state: state }) } @@ -86,14 +84,14 @@ unsafe extern "system" fn notif( .expect("callback ctx should never be null") .lock() .unwrap(); - handle_notif(state_guard); + let Ok(new_list) = crate::list::list_interfaces() else { + return; + }; + handle_notif(state_guard, new_list); } } -fn handle_notif(state: &mut WatchState) { - let Ok(new_list) = crate::list::list_interfaces() else { - return; - }; +fn handle_notif(state: &mut WatchState, new_list: List) { if new_list == state.prev_list { return; } -- 2.39.5