mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-21 15:14:13 +00:00
Kernel: Use the AK SetOnce container class in various cases
We have many places in the kernel code that we have boolean flags that are only set once, and never reset again but are checked multiple times before and after the time they're being set, which matches the purpose of the SetOnce class.
This commit is contained in:
@@ -97,19 +97,19 @@ void IPv4Socket::get_peer_address(sockaddr* address, socklen_t* address_size)
|
||||
|
||||
ErrorOr<void> IPv4Socket::ensure_bound()
|
||||
{
|
||||
dbgln_if(IPV4_SOCKET_DEBUG, "IPv4Socket::ensure_bound() m_bound {}", m_bound);
|
||||
if (m_bound)
|
||||
dbgln_if(IPV4_SOCKET_DEBUG, "IPv4Socket::ensure_bound() m_bound {}", m_bound.was_set());
|
||||
if (m_bound.was_set())
|
||||
return {};
|
||||
|
||||
auto result = protocol_bind();
|
||||
if (!result.is_error())
|
||||
m_bound = true;
|
||||
m_bound.set();
|
||||
return result;
|
||||
}
|
||||
|
||||
ErrorOr<void> IPv4Socket::bind(Credentials const& credentials, Userspace<sockaddr const*> user_address, socklen_t address_size)
|
||||
{
|
||||
if (m_bound)
|
||||
if (m_bound.was_set())
|
||||
return set_so_error(EINVAL);
|
||||
|
||||
VERIFY(setup_state() == SetupState::Unstarted);
|
||||
|
||||
Reference in New Issue
Block a user