Skip to content

Commit

Permalink
Net: Merge Thread::wait_for_connect into LocalSocket (as the only pla…
Browse files Browse the repository at this point in the history
…ce that uses it)

Also do this more like other blockers, don't call yield ourselves, as
block will do that for us.
  • Loading branch information
rburchell authored and awesomekling committed Jul 20, 2019
1 parent 833d444 commit 96de90c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
10 changes: 9 additions & 1 deletion Kernel/Net/LocalSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 0 additions & 14 deletions Kernel/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions Kernel/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ class Thread {

void unblock();

KResult wait_for_connect(FileDescription&);

const FarPtr& far_ptr() const { return m_far_ptr; }

bool tick();
Expand Down

0 comments on commit 96de90c

Please sign in to comment.