diff options
-rw-r--r-- | Kernel/FileSystem/File.h | 2 | ||||
-rw-r--r-- | Kernel/Library/ThreadSafeWeakPtr.h | 16 | ||||
-rw-r--r-- | Kernel/Process.cpp | 3 | ||||
-rw-r--r-- | Kernel/Process.h | 8 | ||||
-rw-r--r-- | Kernel/Syscalls/execve.cpp | 4 | ||||
-rw-r--r-- | Kernel/Syscalls/mmap.cpp | 2 | ||||
-rw-r--r-- | Kernel/Thread.cpp | 2 |
7 files changed, 19 insertions, 18 deletions
diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h index cdc66fd9d8..05dedd9d90 100644 --- a/Kernel/FileSystem/File.h +++ b/Kernel/FileSystem/File.h @@ -128,7 +128,7 @@ protected: // If called from an IRQ handler we need to delay evaluation // and unblocking of waiting threads. Note that this File // instance may be deleted until the deferred call is executed! - Processor::deferred_call_queue([self = make_weak_ptr()]() { + Processor::deferred_call_queue([self = try_make_weak_ptr().release_value_but_fixme_should_propagate_errors()]() { if (auto file = self.strong_ref()) file->do_evaluate_block_conditions(); }); diff --git a/Kernel/Library/ThreadSafeWeakPtr.h b/Kernel/Library/ThreadSafeWeakPtr.h index 5768f9b0a8..ad11e082bb 100644 --- a/Kernel/Library/ThreadSafeWeakPtr.h +++ b/Kernel/Library/ThreadSafeWeakPtr.h @@ -53,7 +53,7 @@ public: template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr> WeakPtr(const U& object) - : m_link(object.template make_weak_ptr<U>().take_link()) + : m_link(object.template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link()) { } @@ -61,7 +61,7 @@ public: WeakPtr(const U* object) { if (object) - m_link = object->template make_weak_ptr<U>().take_link(); + m_link = object->template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link(); } template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr> @@ -69,7 +69,7 @@ public: { object.do_while_locked([&](U* obj) { if (obj) - m_link = obj->template make_weak_ptr<U>().take_link(); + m_link = obj->template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link(); }); } @@ -78,14 +78,14 @@ public: { object.do_while_locked([&](U* obj) { if (obj) - m_link = obj->template make_weak_ptr<U>().take_link(); + m_link = obj->template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link(); }); } template<typename U, typename EnableIf<IsBaseOf<T, U>>::Type* = nullptr> WeakPtr& operator=(const U& object) { - m_link = object.template make_weak_ptr<U>().take_link(); + m_link = object.template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link(); return *this; } @@ -93,7 +93,7 @@ public: WeakPtr& operator=(const U* object) { if (object) - m_link = object->template make_weak_ptr<U>().take_link(); + m_link = object->template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link(); else m_link = nullptr; return *this; @@ -104,7 +104,7 @@ public: { object.do_while_locked([&](U* obj) { if (obj) - m_link = obj->template make_weak_ptr<U>().take_link(); + m_link = obj->template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link(); else m_link = nullptr; }); @@ -116,7 +116,7 @@ public: { object.do_while_locked([&](U* obj) { if (obj) - m_link = obj->template make_weak_ptr<U>().take_link(); + m_link = obj->template try_make_weak_ptr<U>().release_value_but_fixme_should_propagate_errors().take_link(); else m_link = nullptr; }); diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 0cbb1f9449..13e6076a86 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -266,7 +266,8 @@ ErrorOr<void> Process::attach_resources(NonnullOwnPtr<Memory::AddressSpace>&& pr first_thread->detach(); } - m_procfs_traits = TRY(ProcessProcFSTraits::try_create({}, *this)); + auto weak_ptr = TRY(this->try_make_weak_ptr()); + m_procfs_traits = TRY(ProcessProcFSTraits::try_create({}, move(weak_ptr))); return {}; } diff --git a/Kernel/Process.h b/Kernel/Process.h index 2d138403b2..cd94e0426a 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -724,9 +724,9 @@ public: class ProcessProcFSTraits : public ProcFSExposedComponent { public: - static ErrorOr<NonnullRefPtr<ProcessProcFSTraits>> try_create(Badge<Process>, Process& process) + static ErrorOr<NonnullRefPtr<ProcessProcFSTraits>> try_create(Badge<Process>, WeakPtr<Process> process) { - return adopt_nonnull_ref_or_enomem(new (nothrow) ProcessProcFSTraits(process)); + return adopt_nonnull_ref_or_enomem(new (nothrow) ProcessProcFSTraits(move(process))); } virtual InodeIndex component_index() const override; @@ -738,8 +738,8 @@ public: virtual GroupID owner_group() const override; private: - explicit ProcessProcFSTraits(Process& process) - : m_process(process.make_weak_ptr()) + explicit ProcessProcFSTraits(WeakPtr<Process> process) + : m_process(move(process)) { } diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 6984e0fe81..2b9de45c04 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -404,10 +404,10 @@ static ErrorOr<LoadResult> load_elf_object(NonnullOwnPtr<Memory::AddressSpace> n load_base_address, elf_image.entry().offset(load_offset).get(), executable_size, - AK::make_weak_ptr_if_nonnull(master_tls_region), + TRY(AK::try_make_weak_ptr_if_nonnull(master_tls_region)), master_tls_size, master_tls_alignment, - stack_region->make_weak_ptr() + TRY(stack_region->try_make_weak_ptr()) }; } diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index b408657a83..cfe775c20c 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -523,7 +523,7 @@ ErrorOr<FlatPtr> Process::sys$allocate_tls(Userspace<const char*> initial_data, auto range = TRY(address_space().try_allocate_range({}, size)); auto* region = TRY(address_space().allocate_region(range, "Master TLS"sv, PROT_READ | PROT_WRITE)); - m_master_tls_region = region->make_weak_ptr(); + m_master_tls_region = TRY(region->try_make_weak_ptr()); m_master_tls_size = size; m_master_tls_alignment = PAGE_SIZE; diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index f0551c28e6..f7764b85ee 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -359,7 +359,7 @@ void Thread::unblock_from_blocker(Blocker& blocker) unblock(); }; if (Processor::current_in_irq() != 0) { - Processor::deferred_call_queue([do_unblock = move(do_unblock), self = make_weak_ptr()]() { + Processor::deferred_call_queue([do_unblock = move(do_unblock), self = try_make_weak_ptr().release_value_but_fixme_should_propagate_errors()]() { if (auto this_thread = self.strong_ref()) do_unblock(); }); |