1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

LibIPC: Close received IPC::File fd's by default unless taken

When receiving a file descriptor over IPC, the receiver must now call
take_fd() on the IPC::File to take over the descriptor. Otherwise,
IPC::File will close the file on destruction.
This commit is contained in:
Andreas Kling 2021-01-14 09:31:21 +01:00
parent 384d047e3e
commit 7f2d8e8884
5 changed files with 50 additions and 5 deletions

View file

@ -59,7 +59,7 @@ RefPtr<Download> Client::start_download(const String& method, const String& url,
auto download_id = response->download_id();
if (download_id < 0 || !response->response_fd().has_value())
return nullptr;
auto response_fd = response->response_fd().value().fd();
auto response_fd = response->response_fd().value().take_fd();
auto download = Download::create_from_id({}, *this, download_id);
download->set_download_fd({}, response_fd);
m_downloads.set(download_id, download);