Kernel: Add locking to inode's epoll list
This was prone to crashing :)
This commit is contained in:
parent
b90cfa8e5c
commit
553c76ab0f
|
@ -175,6 +175,7 @@ namespace Kernel
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BAN::WeakPtr<SharedFileData> m_shared_region;
|
BAN::WeakPtr<SharedFileData> m_shared_region;
|
||||||
|
Mutex m_epoll_mutex;
|
||||||
BAN::LinkedList<class Epoll*> m_epolls;
|
BAN::LinkedList<class Epoll*> m_epolls;
|
||||||
friend class FileBackedRegion;
|
friend class FileBackedRegion;
|
||||||
friend class OpenFileDescriptorSet;
|
friend class OpenFileDescriptorSet;
|
||||||
|
|
|
@ -264,12 +264,14 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<void> Inode::add_epoll(class Epoll* epoll)
|
BAN::ErrorOr<void> Inode::add_epoll(class Epoll* epoll)
|
||||||
{
|
{
|
||||||
|
LockGuard _(m_epoll_mutex);
|
||||||
TRY(m_epolls.push_back(epoll));
|
TRY(m_epolls.push_back(epoll));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inode::del_epoll(class Epoll* epoll)
|
void Inode::del_epoll(class Epoll* epoll)
|
||||||
{
|
{
|
||||||
|
LockGuard _(m_epoll_mutex);
|
||||||
for (auto it = m_epolls.begin(); it != m_epolls.end(); it++)
|
for (auto it = m_epolls.begin(); it != m_epolls.end(); it++)
|
||||||
{
|
{
|
||||||
if (*it != epoll)
|
if (*it != epoll)
|
||||||
|
@ -281,6 +283,7 @@ namespace Kernel
|
||||||
|
|
||||||
void Inode::epoll_notify(uint32_t event)
|
void Inode::epoll_notify(uint32_t event)
|
||||||
{
|
{
|
||||||
|
LockGuard _(m_epoll_mutex);
|
||||||
for (auto* epoll : m_epolls)
|
for (auto* epoll : m_epolls)
|
||||||
epoll->notify(this, event);
|
epoll->notify(this, event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue