mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
write_queued_bytes_without_blocking() used to allocate a Vector sized to the entire queued response buffer and memcpy every queued byte into it, on every curl on_data_received callback. When the client pipe was slower than the network, the buffer grew, and each arriving chunk triggered a full copy of everything still queued. With enough pending data this added up to tens of gigabytes of memcpy per request and stalled RequestServer for tens of seconds. Drain the stream in a loop using peek_some_contiguous() + send() directly from the underlying chunk, and discard exactly what the socket accepted. No intermediate buffer, no copy. The loop exits on EAGAIN and enables the writer notifier, matching the previous back-pressure behavior.