1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 15:25:07 +00:00

Kernel: Convert IPv4 socket list from HashTable to IntrusiveList

There was no reason whatsoever to use a HashTable here. IntrusiveList
removes all the heap allocations and does everything more efficiently.
This commit is contained in:
Andreas Kling 2021-08-15 15:46:35 +02:00
parent a154faebb7
commit 7063303022
3 changed files with 17 additions and 10 deletions

View file

@ -224,9 +224,11 @@ void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet,
{
NonnullRefPtrVector<IPv4Socket> icmp_sockets;
IPv4Socket::all_sockets().for_each_shared([&](const auto& socket) {
if (socket->protocol() == (unsigned)IPv4Protocol::ICMP)
icmp_sockets.append(*socket);
IPv4Socket::all_sockets().with_exclusive([&](auto& sockets) {
for (auto& socket : sockets) {
if (socket.protocol() == (unsigned)IPv4Protocol::ICMP)
icmp_sockets.append(socket);
}
});
for (auto& socket : icmp_sockets)
socket.did_receive(ipv4_packet.source(), 0, { &ipv4_packet, sizeof(IPv4Packet) + ipv4_packet.payload_size() }, packet_timestamp);