File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -122,17 +122,28 @@ function __init__()
122
122
end
123
123
function exit_hook ()
124
124
exit_flag[] = true
125
+
125
126
evict_delay = DISKCACHE_CONFIG[]. evict_delay
126
127
kill_counter = evict_delay
128
+
129
+ function datastore_empty (do_lock= true )
130
+ with_lock (datastore_lock, do_lock) do
131
+ all (ref-> storage_read (ref). root isa CPURAMDevice, values (datastore))
132
+ end
133
+ end
134
+
135
+ # Wait for datastore objects to naturally expire
127
136
GC. gc ()
128
137
yield ()
129
- while kill_counter > 0 && with_lock (() -> ! isempty (datastore), datastore_lock )
138
+ while kill_counter > 0 && ! datastore_empty ( )
130
139
GC. gc ()
131
140
sleep (1 )
132
141
kill_counter -= 1
133
142
end
143
+
144
+ # Forcibly evict remaining objects
134
145
with_lock (datastore_lock) do
135
- if length (datastore) > 0
146
+ if ! datastore_empty ( false )
136
147
@debug " Failed to cleanup datastore after $evict_delay seconds\n Forcibly evicting all entries"
137
148
for id in collect (keys (datastore))
138
149
state = MemPool. datastore[id]
You can’t perform that action at this time.
0 commit comments