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

Kernel: Drop the receive buffer when socket enters the TimeWait state

The TimeWait state is intended to prevent another socket from taking the
address tuple in case any packets are still in transit after the final
close. Since this state never delivers packets to userspace, it doesn't
make sense to keep the receive buffer around.
This commit is contained in:
sin-ack 2021-09-16 00:15:36 +00:00 committed by Andreas Kling
parent f4d3c54c12
commit 0ccef94a49
3 changed files with 19 additions and 1 deletions

View file

@ -91,6 +91,7 @@ protected:
void set_peer_address(IPv4Address address) { m_peer_address = address; }
static KResultOr<NonnullOwnPtr<DoubleBuffer>> try_create_receive_buffer();
void drop_receive_buffer();
private:
virtual bool is_ipv4() const override { return true; }
@ -115,7 +116,7 @@ private:
SinglyLinkedListWithCount<ReceivedPacket> m_receive_queue;
NonnullOwnPtr<DoubleBuffer> m_receive_buffer;
OwnPtr<DoubleBuffer> m_receive_buffer;
u16 m_local_port { 0 };
u16 m_peer_port { 0 };