1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

Kernel: Use a more detailed state machine for socket setup

This commit is contained in:
Conrad Pankoff 2019-08-10 13:17:00 +10:00 committed by Andreas Kling
parent 638008da13
commit bd6d2c0819
8 changed files with 64 additions and 11 deletions

View file

@ -41,7 +41,7 @@ bool LocalSocket::get_peer_address(sockaddr* address, socklen_t* address_size)
KResult LocalSocket::bind(const sockaddr* address, socklen_t address_size)
{
ASSERT(!is_connected());
ASSERT(setup_state() == SetupState::Unstarted);
if (address_size != sizeof(sockaddr_un))
return KResult(-EINVAL);
if (address->sa_family != AF_LOCAL)
@ -68,6 +68,7 @@ KResult LocalSocket::bind(const sockaddr* address, socklen_t address_size)
m_address = local_address;
m_bound = true;
set_setup_state(SetupState::Completed);
return KSuccess;
}
@ -109,6 +110,10 @@ KResult LocalSocket::connect(FileDescription& description, const sockaddr* addre
if (current->block<Thread::ConnectBlocker>(description) == Thread::BlockResult::InterruptedBySignal)
return KResult(-EINTR);
#ifdef DEBUG_LOCAL_SOCKET
kprintf("%s(%u) LocalSocket{%p} connect(%s) status is %s\n", current->process().name().characters(), current->pid(), this, safe_address, to_string(setup_state()));
#endif
if (!is_connected())
return KResult(-ECONNREFUSED);
return KSuccess;