diff options
author | Robin Burchell <robin+git@viroteck.net> | 2019-07-20 11:10:46 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-20 12:15:24 +0200 |
commit | 96de90ceef95199140f30ac278f0fc1d1b9732c0 (patch) | |
tree | 00971815eb6779c45d820996f2f920e6d5cd190e /Kernel | |
parent | 833d444cd806c490041da4420f5286e59c1c5ed4 (diff) | |
download | serenity-96de90ceef95199140f30ac278f0fc1d1b9732c0.zip |
Net: Merge Thread::wait_for_connect into LocalSocket (as the only place that uses it)
Also do this more like other blockers, don't call yield ourselves, as
block will do that for us.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Net/LocalSocket.cpp | 10 | ||||
-rw-r--r-- | Kernel/Thread.cpp | 14 | ||||
-rw-r--r-- | Kernel/Thread.h | 2 |
3 files changed, 9 insertions, 17 deletions
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 16f7edfbde..63cc07ecaf 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -103,7 +103,15 @@ KResult LocalSocket::connect(FileDescription& description, const sockaddr* addre if (result.is_error()) return result; - return current->wait_for_connect(description); + if (is_connected()) + return KSuccess; + + if (current->block<Thread::ConnectBlocker>(description) == Thread::BlockResult::InterruptedBySignal) + return KResult(-EINTR); + + if (!is_connected()) + return KResult(-ECONNREFUSED); + return KSuccess; } void LocalSocket::attach(FileDescription& description) diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index b2f5dd38d6..68709dd48d 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -513,20 +513,6 @@ Thread* Thread::clone(Process& process) return clone; } -KResult Thread::wait_for_connect(FileDescription& description) -{ - ASSERT(description.is_socket()); - auto& socket = *description.socket(); - if (socket.is_connected()) - return KSuccess; - if (block<Thread::ConnectBlocker>(description) == Thread::BlockResult::InterruptedBySignal) - return KResult(-EINTR); - Scheduler::yield(); - if (!socket.is_connected()) - return KResult(-ECONNREFUSED); - return KSuccess; -} - void Thread::initialize() { g_runnable_threads = new SchedulerThreadList; diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 5a9ebc895e..de619ba4e4 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -233,8 +233,6 @@ public: void unblock(); - KResult wait_for_connect(FileDescription&); - const FarPtr& far_ptr() const { return m_far_ptr; } bool tick(); |