mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +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
Notes:
sideshowbarker
2024-07-17 07:25:39 +09:00
Author: https://github.com/gunnarbeutner
Commit: a9888d4ea0
Pull-request: https://github.com/SerenityOS/serenity/pull/15874
Reviewed-by: https://github.com/FireFox317
Reviewed-by: https://github.com/linusg
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