mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:57:35 +00:00
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.
This commit is contained in:
parent
833d444cd8
commit
96de90ceef
3 changed files with 9 additions and 17 deletions
|
@ -103,7 +103,15 @@ KResult LocalSocket::connect(FileDescription& description, const sockaddr* addre
|
||||||
if (result.is_error())
|
if (result.is_error())
|
||||||
return result;
|
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)
|
void LocalSocket::attach(FileDescription& description)
|
||||||
|
|
|
@ -513,20 +513,6 @@ Thread* Thread::clone(Process& process)
|
||||||
return clone;
|
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()
|
void Thread::initialize()
|
||||||
{
|
{
|
||||||
g_runnable_threads = new SchedulerThreadList;
|
g_runnable_threads = new SchedulerThreadList;
|
||||||
|
|
|
@ -233,8 +233,6 @@ public:
|
||||||
|
|
||||||
void unblock();
|
void unblock();
|
||||||
|
|
||||||
KResult wait_for_connect(FileDescription&);
|
|
||||||
|
|
||||||
const FarPtr& far_ptr() const { return m_far_ptr; }
|
const FarPtr& far_ptr() const { return m_far_ptr; }
|
||||||
|
|
||||||
bool tick();
|
bool tick();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue