mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-25 09:04:53 +00:00
Kernel: Make TCPSocket client construction use KResultOr and TRY()
We don't really have anywhere to propagate the error in NetworkTask at the moment, since it runs in its own kernel thread and has no direct userspace caller.
This commit is contained in:
@@ -449,11 +449,12 @@ void handle_tcp(IPv4Packet const& ipv4_packet, Time const& packet_timestamp)
|
||||
dbgln_if(TCP_DEBUG, "handle_tcp: incoming connection");
|
||||
auto& local_address = ipv4_packet.destination();
|
||||
auto& peer_address = ipv4_packet.source();
|
||||
auto client = socket->create_client(local_address, tcp_packet.destination_port(), peer_address, tcp_packet.source_port());
|
||||
if (!client) {
|
||||
dmesgln("handle_tcp: couldn't create client socket");
|
||||
auto client_or_error = socket->try_create_client(local_address, tcp_packet.destination_port(), peer_address, tcp_packet.source_port());
|
||||
if (client_or_error.is_error()) {
|
||||
dmesgln("handle_tcp: couldn't create client socket: {}", client_or_error.error());
|
||||
return;
|
||||
}
|
||||
auto client = client_or_error.release_value();
|
||||
MutexLocker locker(client->mutex());
|
||||
dbgln_if(TCP_DEBUG, "handle_tcp: created new client socket with tuple {}", client->tuple().to_string());
|
||||
client->set_sequence_number(1000);
|
||||
|
||||
Reference in New Issue
Block a user