mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 19:25:07 +00:00
Kernel: Make Inode::register_watcher() OOM-fallible
This commit is contained in:
parent
87bd930e7e
commit
a9cd8ca841
3 changed files with 14 additions and 7 deletions
|
@ -124,13 +124,19 @@ ErrorOr<int> InodeWatcher::register_inode(Inode& inode, unsigned event_mask)
|
|||
auto description = TRY(WatchDescription::create(wd, inode, event_mask));
|
||||
|
||||
TRY(m_inode_to_watches.try_set(inode.identifier(), description.ptr()));
|
||||
auto result = m_wd_to_watches.try_set(wd, move(description));
|
||||
if (result.is_error()) {
|
||||
auto set_result = m_wd_to_watches.try_set(wd, move(description));
|
||||
if (set_result.is_error()) {
|
||||
m_inode_to_watches.remove(inode.identifier());
|
||||
return result.release_error();
|
||||
return set_result.release_error();
|
||||
}
|
||||
|
||||
auto register_result = inode.register_watcher({}, *this);
|
||||
if (register_result.is_error()) {
|
||||
m_inode_to_watches.remove(inode.identifier());
|
||||
m_wd_to_watches.remove(wd);
|
||||
return register_result.release_error();
|
||||
}
|
||||
|
||||
inode.register_watcher({}, *this);
|
||||
return wd;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue