1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 07:54:58 +00:00

Kernel: Add Socket::set_role() and use it everywhere

Instead of having Socket subclasses write their role into Socket::m_role
directly, add a setter to do this.
This commit is contained in:
Andreas Kling 2021-08-29 02:04:30 +02:00
parent 70b2225b3d
commit a28cd921a1
6 changed files with 10 additions and 8 deletions

View file

@ -39,7 +39,7 @@ void TCPSocket::set_state(State new_state)
m_state = new_state;
if (new_state == State::Established && m_direction == Direction::Outgoing) {
m_role = Role::Connected;
set_role(Role::Connected);
[[maybe_unused]] auto rc = set_so_error(KSuccess);
}
@ -416,7 +416,7 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
if (auto result = send_tcp_packet(TCPFlags::SYN); result.is_error())
return result;
m_state = State::SynSent;
m_role = Role::Connecting;
set_role(Role::Connecting);
m_direction = Direction::Outgoing;
evaluate_block_conditions();
@ -429,7 +429,7 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
locker.lock();
VERIFY(setup_state() == SetupState::Completed);
if (has_error()) { // TODO: check unblock_flags
m_role = Role::None;
set_role(Role::None);
if (error() == TCPSocket::Error::RetransmitTimeout)
return set_so_error(ETIMEDOUT);
else