mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-23 08:06:11 +00:00
Kernel: Use a more detailed state machine for socket setup
This commit is contained in:
committed by
Andreas Kling
parent
638008da13
commit
bd6d2c0819
@@ -70,6 +70,7 @@ SocketHandle<TCPSocket> TCPSocket::create_client(const IPv4Address& new_local_ad
|
||||
|
||||
auto client = TCPSocket::create(protocol());
|
||||
|
||||
client->set_setup_state(SetupState::InProgress);
|
||||
client->set_local_address(new_local_address);
|
||||
client->set_local_port(new_local_port);
|
||||
client->set_peer_address(new_peer_address);
|
||||
@@ -239,7 +240,7 @@ KResult TCPSocket::protocol_listen()
|
||||
sockets_by_tuple().resource().set(tuple(), this);
|
||||
set_direction(Direction::Passive);
|
||||
set_state(State::Listen);
|
||||
set_connected(true);
|
||||
set_setup_state(SetupState::Completed);
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
@@ -264,6 +265,7 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
|
||||
m_sequence_number = 0;
|
||||
m_ack_number = 0;
|
||||
|
||||
set_setup_state(SetupState::InProgress);
|
||||
send_tcp_packet(TCPFlags::SYN);
|
||||
m_state = State::SynSent;
|
||||
m_direction = Direction::Outgoing;
|
||||
@@ -271,7 +273,7 @@ KResult TCPSocket::protocol_connect(FileDescription& description, ShouldBlock sh
|
||||
if (should_block == ShouldBlock::Yes) {
|
||||
if (current->block<Thread::ConnectBlocker>(description) == Thread::BlockResult::InterruptedBySignal)
|
||||
return KResult(-EINTR);
|
||||
ASSERT(is_connected());
|
||||
ASSERT(setup_state() == SetupState::Completed);
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user