mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
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).
This commit is contained in:
parent
bdd4b99d72
commit
6422a04cda
Notes:
sideshowbarker
2024-07-19 00:21:38 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/6422a04cdae Pull-request: https://github.com/SerenityOS/serenity/pull/4665
2 changed files with 5 additions and 2 deletions
|
@ -54,8 +54,9 @@ public:
|
|||
~InputFileStream()
|
||||
{
|
||||
if (m_file) {
|
||||
fflush(m_file);
|
||||
if (m_owned)
|
||||
fflush(m_file);
|
||||
fclose(m_file);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue