File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -129,15 +129,15 @@ impl CallbackHandler {
129129 handle : UnicastCallbackHandle ,
130130 ) -> Result < ( ) , Error > {
131131 trace ! ( "unregistering unicast callback" ) ;
132- if self
133- . unicast_callbacks
134- . remove ( & ( handle. 0 . 0 as isize ) )
135- . is_some ( )
136- {
132+ let key = handle. 0 . 0 as isize ;
133+ if self . unicast_callbacks . contains_key ( & key) {
134+ // Cancel first to ensure no in-flight callbacks reference the Arc,
135+ // then remove the Arc from the map.
137136 unsafe {
138137 windows:: Win32 :: NetworkManagement :: IpHelper :: CancelMibChangeNotify2 ( handle. 0 )
139138 . ok ( ) ?;
140139 }
140+ self . unicast_callbacks . remove ( & key) ;
141141 }
142142
143143 Ok ( ( ) )
@@ -171,15 +171,15 @@ impl CallbackHandler {
171171 handle : RouteCallbackHandle ,
172172 ) -> Result < ( ) , Error > {
173173 trace ! ( "unregistering route callback" ) ;
174- if self
175- . route_callbacks
176- . remove ( & ( handle. 0 . 0 as isize ) )
177- . is_some ( )
178- {
174+ let key = handle. 0 . 0 as isize ;
175+ if self . route_callbacks . contains_key ( & key) {
176+ // Cancel first to ensure no in-flight callbacks reference the Arc,
177+ // then remove the Arc from the map.
179178 unsafe {
180179 windows:: Win32 :: NetworkManagement :: IpHelper :: CancelMibChangeNotify2 ( handle. 0 )
181180 . ok ( ) ?;
182181 }
182+ self . route_callbacks . remove ( & key) ;
183183 }
184184
185185 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments