mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:04:57 +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:
parent
f4d3c54c12
commit
0ccef94a49
3 changed files with 19 additions and 1 deletions
|
@ -43,6 +43,13 @@ void TCPSocket::set_state(State new_state)
|
|||
[[maybe_unused]] auto rc = set_so_error(KSuccess);
|
||||
}
|
||||
|
||||
if (new_state == State::TimeWait) {
|
||||
// Once we hit TimeWait, we are only holding the socket in case there
|
||||
// are packets on the way which we wouldn't want a new socket to get hit
|
||||
// with, so there's no point in keeping the receive buffer around.
|
||||
drop_receive_buffer();
|
||||
}
|
||||
|
||||
if (new_state == State::Closed) {
|
||||
closing_sockets().with_exclusive([&](auto& table) {
|
||||
table.remove(tuple());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue