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

Kernel: Migrate IPv4 socket table locking to ProtectedValue

This commit is contained in:
Jean-Baptiste Boric 2021-07-18 11:59:25 +02:00 committed by Andreas Kling
parent edd6c04024
commit 583abc27d8
4 changed files with 15 additions and 15 deletions

View file

@ -223,14 +223,10 @@ void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet,
{
NonnullRefPtrVector<IPv4Socket> icmp_sockets;
{
MutexLocker locker(IPv4Socket::all_sockets().lock(), Mutex::Mode::Shared);
for (auto* socket : IPv4Socket::all_sockets().resource()) {
if (socket->protocol() != (unsigned)IPv4Protocol::ICMP)
continue;
IPv4Socket::all_sockets().for_each_shared([&](const auto& socket) {
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);
}