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
commit 0ccef94a49
Notes: sideshowbarker 2024-07-18 03:53:04 +09:00
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 };