diff options
author | Andreas Kling <kling@serenityos.org> | 2021-01-14 09:39:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-14 09:50:14 +0100 |
commit | f1f7bf567bb54ef9fb56e06907ab4a2237601115 (patch) | |
tree | 2d0806aec120bfa4d1ceb5fa6adec0be9ce118ce /Userland/Libraries/LibIPC | |
parent | 7f2d8e88841bd1daf5583e24be4efb2946fc8402 (diff) | |
download | serenity-f1f7bf567bb54ef9fb56e06907ab4a2237601115.zip |
LibIPC: Add an expressive way to close an IPC::File after sending it
If you don't need a file descriptor after sending it to someone over
IPC, construct it with IPC::File(fd, IPC::File::CloseAfterSending)
and LibIPC will take care of it for you. :^)
Diffstat (limited to 'Userland/Libraries/LibIPC')
-rw-r--r-- | Userland/Libraries/LibIPC/File.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibIPC/Message.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibIPC/Message.h | 2 |
3 files changed, 2 insertions, 4 deletions
diff --git a/Userland/Libraries/LibIPC/File.h b/Userland/Libraries/LibIPC/File.h index f18d6a6f15..51d14633f4 100644 --- a/Userland/Libraries/LibIPC/File.h +++ b/Userland/Libraries/LibIPC/File.h @@ -48,8 +48,10 @@ public: } // Tagged constructor for fd's that should be closed on destruction unless take_fd() is called. + // Note that the tags are the same, this is intentional to allow expressive invocation. enum Tag { ConstructWithReceivedFileDescriptor = 1, + CloseAfterSending = 1, }; File(int fd, Tag) : m_fd(fd) diff --git a/Userland/Libraries/LibIPC/Message.cpp b/Userland/Libraries/LibIPC/Message.cpp index 7d3e40dcf6..10919b70de 100644 --- a/Userland/Libraries/LibIPC/Message.cpp +++ b/Userland/Libraries/LibIPC/Message.cpp @@ -34,8 +34,6 @@ Message::Message() Message::~Message() { - if (on_destruction) - on_destruction(); } } diff --git a/Userland/Libraries/LibIPC/Message.h b/Userland/Libraries/LibIPC/Message.h index 90dc57bb5e..c45d9165f9 100644 --- a/Userland/Libraries/LibIPC/Message.h +++ b/Userland/Libraries/LibIPC/Message.h @@ -45,8 +45,6 @@ public: virtual const char* message_name() const = 0; virtual MessageBuffer encode() const = 0; - Function<void()> on_destruction; - protected: Message(); }; |