@@ -242,35 +242,27 @@ impl FilesystemStoreInner {
242
242
} )
243
243
} ;
244
244
245
- self . clean_locks ( & inner_lock_ref, dest_file_path, & async_state ) ;
245
+ self . clean_locks ( & inner_lock_ref, dest_file_path) ;
246
246
247
247
res
248
248
}
249
249
250
250
fn execute_locked_read < F : FnOnce ( ) -> Result < ( ) , lightning:: io:: Error > > (
251
251
& self , inner_lock_ref : Arc < RwLock < AsyncState > > , dest_file_path : PathBuf , callback : F ,
252
252
) -> Result < ( ) , lightning:: io:: Error > {
253
- let async_state = inner_lock_ref. read ( ) . unwrap ( ) ;
254
-
255
- // If the version is not stale, we execute the callback. Otherwise we can and must skip writing.
253
+ let _async_state = inner_lock_ref. read ( ) . unwrap ( ) ;
256
254
let res = callback ( ) ;
257
-
258
- self . clean_locks ( & inner_lock_ref, dest_file_path, & async_state) ;
259
-
255
+ self . clean_locks ( & inner_lock_ref, dest_file_path) ;
260
256
res
261
257
}
262
258
263
- fn clean_locks (
264
- & self , inner_lock_ref : & Arc < RwLock < AsyncState > > , dest_file_path : PathBuf ,
265
- async_state : & AsyncState ,
266
- ) {
267
- let more_writes_pending = async_state. latest_written_version < async_state. latest_version ;
268
-
269
- // If there are no more writes pending and no arcs in use elsewhere, we can remove the map entry to prevent
270
- // leaking memory. The two arcs are the one in the map and the one held here in inner_lock_ref. The outer lock
271
- // is obtained first, to avoid a new arc being cloned after we've already counted.
259
+ fn clean_locks ( & self , inner_lock_ref : & Arc < RwLock < AsyncState > > , dest_file_path : PathBuf ) {
260
+ // If there no arcs in use elsewhere, this means that there are no in-flight writes. We can remove the map entry
261
+ // to prevent leaking memory. The two arcs that are expected are the one in the map and the one held here in
262
+ // inner_lock_ref. The outer lock is obtained first, to avoid a new arc being cloned after we've already
263
+ // counted.
272
264
let mut outer_lock = self . locks . lock ( ) . unwrap ( ) ;
273
- if !more_writes_pending && Arc :: strong_count ( & inner_lock_ref) == 2 {
265
+ if Arc :: strong_count ( & inner_lock_ref) == 2 {
274
266
outer_lock. remove ( & dest_file_path) ;
275
267
}
276
268
}
0 commit comments