RequestServer+LibHTTP: Cancel requests on client exit

That usually happens in "exceptional" states when the client exits
unexpectedly (crash, force quit mid-load, etc), leading to the job flush
timer firing and attempting to write to a nonexistent object (the
client).

This commit makes RS simply cancel such jobs; cancelled jobs in this
state simply go away instead of sending notifications around.
This commit is contained in:
Ali Mohammad Pur 2024-07-28 00:22:58 +02:00 committed by Ali Mohammad Pur
commit 4211639e45
Notes: github-actions[bot] 2024-07-28 11:46:35 +00:00
8 changed files with 25 additions and 7 deletions

View file

@ -576,6 +576,13 @@ void Job::finish_up()
{
VERIFY(!m_has_scheduled_finish);
m_state = State::Finished;
if (is_cancelled()) {
stop_timer();
m_has_scheduled_finish = true;
return;
}
if (!m_can_stream_response) {
auto maybe_flattened_buffer = ByteBuffer::create_uninitialized(m_buffered_size);
if (maybe_flattened_buffer.is_error())