mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
IPv4: Protect the list of unacked TCP packets with a lock
Otherwise things get racy and crashy.
This commit is contained in:
parent
dc9d44d7b1
commit
61f611bf3c
2 changed files with 4 additions and 0 deletions
|
@ -162,6 +162,7 @@ void TCPSocket::send_tcp_packet(u16 flags, const void* payload, int payload_size
|
||||||
tcp_packet.set_checksum(compute_tcp_checksum(local_address(), peer_address(), tcp_packet, payload_size));
|
tcp_packet.set_checksum(compute_tcp_checksum(local_address(), peer_address(), tcp_packet, payload_size));
|
||||||
|
|
||||||
if (tcp_packet.has_syn() || payload_size > 0) {
|
if (tcp_packet.has_syn() || payload_size > 0) {
|
||||||
|
LOCKER(m_not_acked_lock);
|
||||||
m_not_acked.append({ m_sequence_number, move(buffer), 0, {} });
|
m_not_acked.append({ m_sequence_number, move(buffer), 0, {} });
|
||||||
send_outgoing_packets();
|
send_outgoing_packets();
|
||||||
return;
|
return;
|
||||||
|
@ -185,6 +186,7 @@ void TCPSocket::send_outgoing_packets()
|
||||||
|
|
||||||
auto now = kgettimeofday();
|
auto now = kgettimeofday();
|
||||||
|
|
||||||
|
LOCKER(m_not_acked_lock);
|
||||||
for (auto& packet : m_not_acked) {
|
for (auto& packet : m_not_acked) {
|
||||||
timeval diff;
|
timeval diff;
|
||||||
timeval_sub(packet.tx_time, now, diff);
|
timeval_sub(packet.tx_time, now, diff);
|
||||||
|
@ -228,6 +230,7 @@ void TCPSocket::receive_tcp_packet(const TCPPacket& packet, u16 size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
LOCKER(m_not_acked_lock);
|
||||||
while (!m_not_acked.is_empty()) {
|
while (!m_not_acked.is_empty()) {
|
||||||
auto& packet = m_not_acked.first();
|
auto& packet = m_not_acked.first();
|
||||||
|
|
||||||
|
|
|
@ -172,5 +172,6 @@ private:
|
||||||
timeval tx_time;
|
timeval tx_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Lock m_not_acked_lock { "TCPSocket unacked packets" };
|
||||||
SinglyLinkedList<OutgoingPacket> m_not_acked;
|
SinglyLinkedList<OutgoingPacket> m_not_acked;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue