mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
Kernel: Use non-locking {Nonnull,}RefPtr for OpenFileDescription
This patch switches away from {Nonnull,}LockRefPtr to the non-locking smart pointers throughout the kernel. I've looked at the handful of places where these were being persisted and I don't see any race situations. Note that the process file descriptor table (Process::m_fds) was already guarded via MutexProtected.
This commit is contained in:
parent
36b0ecfe9e
commit
d1371d66f7
34 changed files with 82 additions and 80 deletions
|
@ -570,13 +570,13 @@ Process::OpenFileDescriptionAndFlags& Process::OpenFileDescriptions::at(size_t i
|
|||
return m_fds_metadatas[i];
|
||||
}
|
||||
|
||||
ErrorOr<NonnullLockRefPtr<OpenFileDescription>> Process::OpenFileDescriptions::open_file_description(int fd) const
|
||||
ErrorOr<NonnullRefPtr<OpenFileDescription>> Process::OpenFileDescriptions::open_file_description(int fd) const
|
||||
{
|
||||
if (fd < 0)
|
||||
return EBADF;
|
||||
if (static_cast<size_t>(fd) >= m_fds_metadatas.size())
|
||||
return EBADF;
|
||||
LockRefPtr description = m_fds_metadatas[fd].description();
|
||||
RefPtr description = m_fds_metadatas[fd].description();
|
||||
if (!description)
|
||||
return EBADF;
|
||||
return description.release_nonnull();
|
||||
|
@ -706,7 +706,7 @@ ErrorOr<void> Process::dump_perfcore()
|
|||
return KString::formatted("{}_{}", process_name->view(), pid().value());
|
||||
}));
|
||||
auto perfcore_filename = TRY(KString::formatted("{}.profile", base_filename));
|
||||
LockRefPtr<OpenFileDescription> description;
|
||||
RefPtr<OpenFileDescription> description;
|
||||
auto credentials = this->credentials();
|
||||
for (size_t attempt = 1; attempt <= 10; ++attempt) {
|
||||
auto description_or_error = VirtualFileSystem::the().open(*this, credentials, perfcore_filename->view(), O_CREAT | O_EXCL, 0400, current_directory(), UidAndGid { 0, 0 });
|
||||
|
@ -945,7 +945,7 @@ void Process::OpenFileDescriptionAndFlags::clear()
|
|||
m_flags = 0;
|
||||
}
|
||||
|
||||
void Process::OpenFileDescriptionAndFlags::set(NonnullLockRefPtr<OpenFileDescription>&& description, u32 flags)
|
||||
void Process::OpenFileDescriptionAndFlags::set(NonnullRefPtr<OpenFileDescription> description, u32 flags)
|
||||
{
|
||||
m_description = move(description);
|
||||
m_flags = flags;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue