mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:08:10 +00:00
AK+Kernel: Handle some allocation failures in IPv4Socket and TCPSocket
This adds try_* methods to AK::SinglyLinkedList and AK::SinglyLinkedListWithCount and updates the network stack to use those to gracefully handle allocation failures. Refs #6369.
This commit is contained in:
parent
ab8b043684
commit
a9888d4ea0
4 changed files with 92 additions and 30 deletions
|
@ -449,7 +449,11 @@ bool IPv4Socket::did_receive(IPv4Address const& source_address, u16 source_port,
|
|||
dbgln("IPv4Socket: did_receive unable to allocate storage for incoming packet.");
|
||||
return false;
|
||||
}
|
||||
m_receive_queue.append({ source_address, source_port, packet_timestamp, data_or_error.release_value() });
|
||||
auto result = m_receive_queue.try_append({ source_address, source_port, packet_timestamp, data_or_error.release_value() });
|
||||
if (result.is_error()) {
|
||||
dbgln("IPv4Socket: Dropped incoming packet because appending to the receive queue failed.");
|
||||
return false;
|
||||
}
|
||||
set_can_read(true);
|
||||
}
|
||||
m_bytes_received += packet_size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue