1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 21:38:11 +00:00

LibCore: Make sure to disable notifiers when closing a socket

RefPtr<Notifier> doesn't work quite like it appears to, since the notifier
is also a "child" of the socket, in Core::Object sense. Thus we have to both
remove it from the parent (socket) and drop the additional RefPtr<Notifier> for
it to actually go away.

A proper fix for this would be to untangle parent-child relashionship from
refcounting and inspectability.

This fixes use-after-close of client file descriptors in IPC servers.
This commit is contained in:
Sergey Bugaev 2020-06-08 14:29:37 +03:00 committed by Andreas Kling
parent bb19eb8f23
commit 89004a3a40

View file

@ -181,7 +181,14 @@ bool Socket::send(const ByteBuffer& data)
void Socket::did_update_fd(int fd)
{
if (fd < 0) {
m_read_notifier = nullptr;
if (m_read_notifier) {
m_read_notifier->remove_from_parent();
m_read_notifier = nullptr;
}
if (m_notifier) {
m_notifier->remove_from_parent();
m_notifier = nullptr;
}
return;
}
if (m_connected) {