mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:07:35 +00:00
Kernel: LocalSocket should fail with EADDRINUSE for already-bound files
This commit is contained in:
parent
6634da31d9
commit
625ab1f527
2 changed files with 13 additions and 5 deletions
|
@ -168,14 +168,18 @@ void Inode::set_vmobject(VMObject& vmobject)
|
||||||
|
|
||||||
bool Inode::bind_socket(LocalSocket& socket)
|
bool Inode::bind_socket(LocalSocket& socket)
|
||||||
{
|
{
|
||||||
ASSERT(!m_socket);
|
LOCKER(m_lock);
|
||||||
|
if (m_socket)
|
||||||
|
return false;
|
||||||
m_socket = socket;
|
m_socket = socket;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Inode::unbind_socket()
|
bool Inode::unbind_socket()
|
||||||
{
|
{
|
||||||
ASSERT(m_socket);
|
LOCKER(m_lock);
|
||||||
|
if (!m_socket)
|
||||||
|
return false;
|
||||||
m_socket = nullptr;
|
m_socket = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,10 +117,14 @@ KResult LocalSocket::bind(const sockaddr* user_address, socklen_t address_size)
|
||||||
return KResult(-EADDRINUSE);
|
return KResult(-EADDRINUSE);
|
||||||
return result.error();
|
return result.error();
|
||||||
}
|
}
|
||||||
m_file = move(result.value());
|
|
||||||
|
|
||||||
ASSERT(m_file->inode());
|
auto file = move(result.value());
|
||||||
m_file->inode()->bind_socket(*this);
|
|
||||||
|
ASSERT(file->inode());
|
||||||
|
if (!file->inode()->bind_socket(*this))
|
||||||
|
return KResult(-EADDRINUSE);
|
||||||
|
|
||||||
|
m_file = move(file);
|
||||||
|
|
||||||
m_address = address;
|
m_address = address;
|
||||||
m_bound = true;
|
m_bound = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue