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

LibProtocol: Don't block indefinitely in stream_into's on_ready_to_read

Blocking there will lead to blocking the entire event loop, so just try
to read until something has been read or we hit EOF, this allows the
event loop to continue to deliver other events while a long download is
happening.
This commit is contained in:
Ali Mohammad Pur 2022-03-17 20:54:08 +03:30 committed by Andreas Kling
parent dff8344336
commit 6386554cd9

View file

@ -43,7 +43,7 @@ void Request::stream_into_impl(T& stream)
}
};
m_internal_stream_data->read_notifier->on_ready_to_read = [this, &stream] {
constexpr size_t buffer_size = 16 * KiB;
constexpr size_t buffer_size = 256 * KiB;
static char buf[buffer_size];
do {
auto result = m_internal_stream_data->read_stream->read({ buf, buffer_size });
@ -58,6 +58,7 @@ void Request::stream_into_impl(T& stream)
// FIXME: What do we do here?
TODO();
}
break;
} while (true);
if (m_internal_stream_data->read_stream->is_eof())