summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/OpenFileDescription.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-21 01:04:35 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-21 12:25:14 +0200
commit728c3fbd14252bd746f97dbb5441063992074b6b (patch)
tree539c32ede90702ab3ef35b984addad93769db340 /Kernel/FileSystem/OpenFileDescription.h
parent5331d243c690c70e431e2f8d260eacab19946c2b (diff)
downloadserenity-728c3fbd14252bd746f97dbb5441063992074b6b.zip
Kernel: Use RefPtr instead of LockRefPtr for Custody
By protecting all the RefPtr<Custody> objects that may be accessed from multiple threads at the same time (with spinlocks), we remove the need for using LockRefPtr<Custody> (which is basically a RefPtr with a built-in spinlock.)
Diffstat (limited to 'Kernel/FileSystem/OpenFileDescription.h')
-rw-r--r--Kernel/FileSystem/OpenFileDescription.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/Kernel/FileSystem/OpenFileDescription.h b/Kernel/FileSystem/OpenFileDescription.h
index fc513f56cb..c4cdae2d49 100644
--- a/Kernel/FileSystem/OpenFileDescription.h
+++ b/Kernel/FileSystem/OpenFileDescription.h
@@ -8,6 +8,7 @@
#include <AK/AtomicRefCounted.h>
#include <AK/Badge.h>
+#include <AK/RefPtr.h>
#include <Kernel/FileSystem/FIFO.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/FileSystem/InodeMetadata.h>
@@ -88,8 +89,8 @@ public:
Inode* inode() { return m_inode.ptr(); }
Inode const* inode() const { return m_inode.ptr(); }
- Custody* custody() { return m_custody.ptr(); }
- Custody const* custody() const { return m_custody.ptr(); }
+ RefPtr<Custody> custody();
+ RefPtr<Custody const> custody() const;
ErrorOr<Memory::Region*> mmap(Process&, Memory::VirtualRange const&, u64 offset, int prot, bool shared);
@@ -138,12 +139,12 @@ private:
blocker_set().unblock_all_blockers_whose_conditions_are_met();
}
- LockRefPtr<Custody> m_custody;
LockRefPtr<Inode> m_inode;
NonnullLockRefPtr<File> m_file;
struct State {
OwnPtr<OpenFileDescriptionData> data;
+ RefPtr<Custody> custody;
off_t current_offset { 0 };
u32 file_flags { 0 };
bool readable : 1 { false };