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 on_destruction; - protected: Message(); }; diff --git a/Userland/Services/ProtocolServer/ClientConnection.cpp b/Userland/Services/ProtocolServer/ClientConnection.cpp index e966d2f2f4..c03245a7a0 100644 --- a/Userland/Services/ProtocolServer/ClientConnection.cpp +++ b/Userland/Services/ProtocolServer/ClientConnection.cpp @@ -78,9 +78,7 @@ OwnPtr ClientConnection::handle auto id = download->id(); auto fd = download->download_fd(); m_downloads.set(id, move(download)); - auto response = make(id, fd); - response->on_destruction = [fd] { close(fd); }; - return response; + return make(id, IPC::File(fd, IPC::File::CloseAfterSending)); } OwnPtr ClientConnection::handle(const Messages::ProtocolServer::StopDownload& message)