mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
Ext2FS: Don't uncache inodes while they are being watched
If an inode is observed by watch_file(), we won't uncache it. This allows a program to watch a file without keeping it open.
This commit is contained in:
@@ -507,6 +507,8 @@ void Ext2FS::flush_writes()
|
||||
DiskBackedFS::flush_writes();
|
||||
|
||||
// Uncache Inodes that are only kept alive by the index-to-inode lookup cache.
|
||||
// We don't uncache Inodes that are being watched by at least one InodeWatcher.
|
||||
|
||||
// FIXME: It would be better to keep a capped number of Inodes around.
|
||||
// The problem is that they are quite heavy objects, and use a lot of heap memory
|
||||
// for their (child name lookup) and (block list) caches.
|
||||
@@ -514,6 +516,8 @@ void Ext2FS::flush_writes()
|
||||
for (auto& it : m_inode_cache) {
|
||||
if (it.value->ref_count() != 1)
|
||||
continue;
|
||||
if (it.value->has_watchers())
|
||||
continue;
|
||||
unused_inodes.append(it.key);
|
||||
}
|
||||
for (auto index : unused_inodes)
|
||||
|
||||
Reference in New Issue
Block a user