Kenrel: Cleanup locking in close
This commit is contained in:
@@ -400,12 +400,20 @@ namespace Kernel
|
|||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<void> OpenFileDescriptorSet::close(int fd)
|
BAN::ErrorOr<void> OpenFileDescriptorSet::close(int fd)
|
||||||
|
{
|
||||||
|
BAN::RefPtr<OpenFileDescription> open_file;
|
||||||
|
|
||||||
{
|
{
|
||||||
LockGuard _(m_mutex);
|
LockGuard _(m_mutex);
|
||||||
|
|
||||||
TRY(validate_fd(fd));
|
TRY(validate_fd(fd));
|
||||||
|
|
||||||
auto& open_file = m_open_files[fd];
|
open_file = m_open_files[fd];
|
||||||
|
|
||||||
|
m_open_files[fd]->file.inode->on_close(m_open_files[fd]->status_flags);
|
||||||
|
m_open_files[fd] = {};
|
||||||
|
remove_cloexec(fd);
|
||||||
|
}
|
||||||
|
|
||||||
if (auto& flock = open_file->flock; Thread::current().has_process() && flock.lockers.contains(Process::current().pid()))
|
if (auto& flock = open_file->flock; Thread::current().has_process() && flock.lockers.contains(Process::current().pid()))
|
||||||
{
|
{
|
||||||
@@ -429,10 +437,6 @@ namespace Kernel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open_file->file.inode->on_close(open_file->status_flags);
|
|
||||||
open_file = {};
|
|
||||||
remove_cloexec(fd);
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user