1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

ProtocolServer: Avoid blocking all downloads when client stops reading

Fixes #4668.
This commit is contained in:
AnotherTest 2020-12-31 01:42:44 +03:30 committed by Andreas Kling
parent 83fed3fd5d
commit 2568a93b5d
7 changed files with 45 additions and 28 deletions

View file

@ -165,10 +165,12 @@ void Job::finish_up()
m_state = State::Finished;
flush_received_buffers();
if (m_received_size != 0) {
// FIXME: What do we do? ignore it?
// "Transmission failed" is not strictly correct, but let's roll with it for now.
// We have to wait for the client to consume all the downloaded data
// before we can actually call `did_finish`. in a normal flow, this should
// never be hit since the client is reading as we are writing, unless there
// are too many concurrent downloads going on.
deferred_invoke([this](auto&) {
did_fail(Error::TransmissionFailed);
finish_up();
});
return;
}