@@ -242,35 +242,27 @@ impl FilesystemStoreInner {
242242 } )
243243 } ;
244244
245- self . clean_locks ( & inner_lock_ref, dest_file_path, & async_state ) ;
245+ self . clean_locks ( & inner_lock_ref, dest_file_path) ;
246246
247247 res
248248 }
249249
250250 fn execute_locked_read < F : FnOnce ( ) -> Result < ( ) , lightning:: io:: Error > > (
251251 & self , inner_lock_ref : Arc < RwLock < AsyncState > > , dest_file_path : PathBuf , callback : F ,
252252 ) -> 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 ( ) ;
256254 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) ;
260256 res
261257 }
262258
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.
272264 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 {
274266 outer_lock. remove ( & dest_file_path) ;
275267 }
276268 }
0 commit comments