LibIPC: Move early fd deallocation workaround to the transport layer

Reimplements c3121c9d at the transport layer, allowing us to solve the
same problem once, in a single place, for both the LibIPC connection and
MessagePort. This avoids exposing a workaround for a macOS specific Unix
domain socket issue to higher abstraction layers.
This commit is contained in:
Aliaksandr Kalenik 2025-04-07 23:41:24 +02:00 committed by Alexander Kalenik
commit ab35325003
Notes: github-actions[bot] 2025-04-08 19:10:45 +00:00
7 changed files with 78 additions and 128 deletions

View file

@ -7,7 +7,9 @@
#pragma once
#include <AK/Queue.h>
#include <LibIPC/UnprocessedFileDescriptors.h>
#include <LibThreading/MutexProtected.h>
namespace IPC {
@ -48,8 +50,14 @@ private:
ErrorOr<void> transfer(ReadonlyBytes, Vector<int, 1> const& unowned_fds);
NonnullOwnPtr<Core::LocalSocket> m_socket;
NonnullOwnPtr<Threading::Mutex> m_socket_write_mutex;
ByteBuffer m_unprocessed_bytes;
UnprocessedFileDescriptors m_unprocessed_fds;
// After file descriptor is sent, it is moved to the wait queue until an acknowledgement is received from the peer.
// This is necessary to handle a specific behavior of the macOS kernel, which may prematurely garbage-collect the file
// descriptor contained in the message before the peer receives it. https://openradar.me/9477351
NonnullOwnPtr<Threading::MutexProtected<Queue<File>>> m_fds_retained_until_received_by_peer;
};
}