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

Kernel: Convert TCP retransmit queue from HashTable to IntrusiveList

This commit is contained in:
Andreas Kling 2021-08-15 16:37:45 +02:00
parent 7063303022
commit 6a20733fcd
3 changed files with 13 additions and 8 deletions

View file

@ -642,7 +642,7 @@ void retransmit_tcp_packets()
// in case retransmit_packets() realizes that it wants to close the socket. // in case retransmit_packets() realizes that it wants to close the socket.
NonnullRefPtrVector<TCPSocket, 16> sockets; NonnullRefPtrVector<TCPSocket, 16> sockets;
TCPSocket::sockets_for_retransmit().for_each_shared([&](const auto& socket) { TCPSocket::sockets_for_retransmit().for_each_shared([&](const auto& socket) {
sockets.append(*socket); sockets.append(socket);
}); });
for (auto& socket : sockets) { for (auto& socket : sockets) {

View file

@ -512,24 +512,24 @@ KResult TCPSocket::close()
return result; return result;
} }
static Singleton<ProtectedValue<HashTable<TCPSocket*>>> s_sockets_for_retransmit; static Singleton<ProtectedValue<TCPSocket::RetransmitList>> s_sockets_for_retransmit;
ProtectedValue<HashTable<TCPSocket*>>& TCPSocket::sockets_for_retransmit() ProtectedValue<TCPSocket::RetransmitList>& TCPSocket::sockets_for_retransmit()
{ {
return *s_sockets_for_retransmit; return *s_sockets_for_retransmit;
} }
void TCPSocket::enqueue_for_retransmit() void TCPSocket::enqueue_for_retransmit()
{ {
sockets_for_retransmit().with_exclusive([&](auto& table) { sockets_for_retransmit().with_exclusive([&](auto& list) {
table.set(this); list.append(*this);
}); });
} }
void TCPSocket::dequeue_for_retransmit() void TCPSocket::dequeue_for_retransmit()
{ {
sockets_for_retransmit().with_exclusive([&](auto& table) { sockets_for_retransmit().with_exclusive([&](auto& list) {
table.remove(this); list.remove(*this);
}); });
} }

View file

@ -153,7 +153,6 @@ public:
void release_to_originator(); void release_to_originator();
void release_for_accept(RefPtr<TCPSocket>); void release_for_accept(RefPtr<TCPSocket>);
static ProtectedValue<HashTable<TCPSocket*>>& sockets_for_retransmit();
void retransmit_packets(); void retransmit_packets();
virtual KResult close() override; virtual KResult close() override;
@ -222,6 +221,12 @@ private:
// FIXME: Parse window size TCP option from the peer // FIXME: Parse window size TCP option from the peer
u32 m_send_window_size { 64 * KiB }; u32 m_send_window_size { 64 * KiB };
IntrusiveListNode<TCPSocket> m_retransmit_list_node;
public:
using RetransmitList = IntrusiveList<TCPSocket, RawPtr<TCPSocket>, &TCPSocket::m_retransmit_list_node>;
static ProtectedValue<TCPSocket::RetransmitList>& sockets_for_retransmit();
}; };
} }