summaryrefslogtreecommitdiff
path: root/Kernel/Net/Routing.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-08-24 13:11:58 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-24 16:37:28 +0200
commit0c1d41cc8a10595e4449f9cc92681ee9e90e57c2 (patch)
tree4e237364dc4162d8533cc73c8f404806df69b375 /Kernel/Net/Routing.cpp
parentadbf472ca7182c96545f0e54aef58560e27656f6 (diff)
downloadserenity-0c1d41cc8a10595e4449f9cc92681ee9e90e57c2.zip
Kernel: Simplify Blockers so they don't need a "should block" flag
The `m_should_block` member variable that many of the Thread::Blocker subclasses had was really only used to carry state from the constructor to the immediate-unblock-without-blocking escape hatch. This patch refactors the blockers so that we don't need to hold on to this flag after setup_blocker(), and instead the return value from setup_blocker() is the authority on whether the unblock conditions are already met.
Diffstat (limited to 'Kernel/Net/Routing.cpp')
-rw-r--r--Kernel/Net/Routing.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/Kernel/Net/Routing.cpp b/Kernel/Net/Routing.cpp
index 8d8e2482e7..3f5c335818 100644
--- a/Kernel/Net/Routing.cpp
+++ b/Kernel/Net/Routing.cpp
@@ -52,7 +52,6 @@ private:
const IPv4Address m_ip_addr;
Optional<MACAddress>& m_addr;
bool m_did_unblock { false };
- bool m_should_block { true };
};
class ARPTableBlockerSet final : public Thread::BlockerSet {
@@ -90,14 +89,11 @@ ARPTableBlocker::ARPTableBlocker(IPv4Address ip_addr, Optional<MACAddress>& addr
bool ARPTableBlocker::setup_blocker()
{
- if (!add_to_blocker_set(*s_arp_table_blocker_set))
- m_should_block = false;
- return m_should_block;
+ return add_to_blocker_set(*s_arp_table_blocker_set);
}
-void ARPTableBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason reason)
+void ARPTableBlocker::will_unblock_immediately_without_blocking(UnblockImmediatelyReason)
{
- VERIFY(reason == UnblockImmediatelyReason::TimeoutInThePast || !m_should_block);
auto addr = arp_table().with_shared([&](const auto& table) -> auto {
return table.get(ip_addr());
});