File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -267,9 +267,11 @@ impl FilesystemStoreInner {
267267 let more_writes_pending = async_state. latest_written_version < async_state. latest_version ;
268268
269269 // 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.
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.
272+ let mut outer_lock = self . locks . lock ( ) . unwrap ( ) ;
271273 if !more_writes_pending && Arc :: strong_count ( & inner_lock_ref) == 2 {
272- self . locks . lock ( ) . unwrap ( ) . remove ( & dest_file_path) ;
274+ outer_lock . remove ( & dest_file_path) ;
273275 }
274276 }
275277
You can’t perform that action at this time.
0 commit comments