diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-14 21:04:34 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-14 21:04:34 +0100 |
commit | cb5021419ea71d204effb65f604978c017dd813f (patch) | |
tree | 88e344bf1dc4cbbaab6450eabe445cdb89c8286e | |
parent | 69efa3f630141a74ced338b07d8466a5a0e7557f (diff) | |
download | serenity-cb5021419ea71d204effb65f604978c017dd813f.zip |
Kernel: Move Thread::m_joinee_exit_value into the JoinBlocker
There's no need for this to be a permanent Thread member. Just use a
reference in the JoinBlocker instead.
-rw-r--r-- | Kernel/Process.cpp | 6 | ||||
-rw-r--r-- | Kernel/Scheduler.cpp | 3 | ||||
-rw-r--r-- | Kernel/Thread.cpp | 2 | ||||
-rw-r--r-- | Kernel/Thread.h | 6 |
4 files changed, 10 insertions, 7 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index d1f3ab495b..f37ffdd080 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -2906,15 +2906,17 @@ int Process::sys$join_thread(int tid, void** exit_value) // FIXME: EINVAL: 'thread' is not a joinable thread + void* joinee_exit_value = nullptr; + // FIXME: pthread_join() should not be interruptable. Enforce this somehow? - auto result = current->block<Thread::JoinBlocker>(*thread); + auto result = current->block<Thread::JoinBlocker>(*thread, joinee_exit_value); (void)result; // NOTE: 'thread' is very possibly deleted at this point. Clear it just to be safe. thread = nullptr; if (exit_value) - *exit_value = current->m_joinee_exit_value; + *exit_value = joinee_exit_value; return 0; } diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index b072fdfcde..816abd5fed 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -68,8 +68,9 @@ void Scheduler::beep() s_beep_timeout = g_uptime + 100; } -Thread::JoinBlocker::JoinBlocker(Thread& joinee) +Thread::JoinBlocker::JoinBlocker(Thread& joinee, void*& joinee_exit_value) : m_joinee(joinee) + , m_joinee_exit_value(joinee_exit_value) { ASSERT(m_joinee.m_joiner == nullptr); m_joinee.m_joiner = current; diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 208b14cec6..c99d817052 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -240,7 +240,7 @@ void Thread::finalize() if (m_joiner) { ASSERT(m_joiner->m_joinee == this); - m_joiner->m_joinee_exit_value = m_exit_value; + static_cast<JoinBlocker*>(m_joiner->m_blocker)->set_joinee_exit_value(m_exit_value); m_joiner->m_joinee = nullptr; // NOTE: We clear the joiner pointer here as well, to be tidy. m_joiner = nullptr; diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 0d43a197d5..2f3d89d2a0 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -97,12 +97,14 @@ public: class JoinBlocker final : public Blocker { public: - explicit JoinBlocker(Thread& joinee); + explicit JoinBlocker(Thread& joinee, void*& joinee_exit_value); virtual bool should_unblock(Thread&, time_t now_s, long us) override; virtual const char* state_string() const override { return "Joining"; } + void set_joinee_exit_value(void* value) { m_joinee_exit_value = value; } private: Thread& m_joinee; + void*& m_joinee_exit_value; }; class FileDescriptionBlocker : public Blocker { @@ -367,10 +369,8 @@ private: SignalActionData m_signal_action_data[32]; Blocker* m_blocker { nullptr }; - // FIXME: Some of these could probably live in the JoinBlocker object instead. Thread* m_joiner { nullptr }; Thread* m_joinee { nullptr }; - void* m_joinee_exit_value { nullptr }; void* m_exit_value { nullptr }; FPUState* m_fpu_state { nullptr }; |