forked from Bananymous/banan-os
Kernel: Fix some race conditions in TCP stack
Remove race condition if two acks are to be sent one after another. Always unblock semaphore once TCP thread has done something. This allows better chance of TCP sending to succeed. There are multiple places in the networking code that would require thread-safe entering to blocking mode. I should add some API for this so that a lot of race conditions could be removed.
This commit is contained in:
parent
e00b92225d
commit
e77de1804f
|
@ -438,10 +438,8 @@ namespace Kernel
|
|||
{
|
||||
LockGuard _(m_mutex);
|
||||
|
||||
if (m_should_ack)
|
||||
if (m_should_ack.compare_exchange(true, false))
|
||||
{
|
||||
m_should_ack = false;
|
||||
|
||||
ASSERT(m_connection_info.has_value());
|
||||
auto* target_address = reinterpret_cast<const sockaddr*>(&m_connection_info->address);
|
||||
auto target_address_len = m_connection_info->address_len;
|
||||
|
@ -510,6 +508,7 @@ namespace Kernel
|
|||
}
|
||||
}
|
||||
|
||||
m_semaphore.unblock();
|
||||
m_semaphore.block_with_wake_time(current_ms + retransmit_timeout_ms);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue