summaryrefslogtreecommitdiff
path: root/Services/ProtocolServer/ClientConnection.cpp
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-12-30 21:05:54 +0330
committerAndreas Kling <kling@serenityos.org>2020-12-30 20:37:41 +0100
commit6422a04cdae10f4e633cbc532ae576ceb23f791a (patch)
treef51cae2efce08148b81e3d1dcc44cc6de140054f /Services/ProtocolServer/ClientConnection.cpp
parentbdd4b99d725188944b207cee20bef5f557fa7849 (diff)
downloadserenity-6422a04cdae10f4e633cbc532ae576ceb23f791a.zip
AK+ProtocolServer: Properly close download stream fd's
This makes the issue of running out of openable pipes in the ProtocolServer process much less likely (but still possible).
Diffstat (limited to 'Services/ProtocolServer/ClientConnection.cpp')
-rw-r--r--Services/ProtocolServer/ClientConnection.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Services/ProtocolServer/ClientConnection.cpp b/Services/ProtocolServer/ClientConnection.cpp
index eee7277869..45ef0e2683 100644
--- a/Services/ProtocolServer/ClientConnection.cpp
+++ b/Services/ProtocolServer/ClientConnection.cpp
@@ -72,7 +72,9 @@ OwnPtr<Messages::ProtocolServer::StartDownloadResponse> ClientConnection::handle
auto id = download->id();
auto fd = download->download_fd();
m_downloads.set(id, move(download));
- return make<Messages::ProtocolServer::StartDownloadResponse>(id, fd);
+ auto response = make<Messages::ProtocolServer::StartDownloadResponse>(id, fd);
+ response->on_destruction = [fd] { close(fd); };
+ return response;
}
OwnPtr<Messages::ProtocolServer::StopDownloadResponse> ClientConnection::handle(const Messages::ProtocolServer::StopDownload& message)