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

Kernel: Avoid allocating and then freeing packet buffers

We already have another limit for the total number of packet buffers
allowed (max_packet_buffers). This second limit caused us to
repeatedly allocate and then free buffers.
This commit is contained in:
Gunnar Beutner 2021-05-12 17:24:50 +02:00 committed by Andreas Kling
parent 55c3a5969c
commit 76deda802d

View file

@ -199,10 +199,8 @@ size_t NetworkAdapter::dequeue_packet(u8* buffer, size_t buffer_size, Time& pack
size_t packet_size = packet.size();
VERIFY(packet_size <= buffer_size);
memcpy(buffer, packet.data(), packet_size);
if (m_unused_packet_buffers_count < 100) {
m_unused_packet_buffers.append(packet);
++m_unused_packet_buffers_count;
}
m_unused_packet_buffers.append(packet);
++m_unused_packet_buffers_count;
return packet_size;
}