1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-15 19:57:36 +00:00

LibCore: Make CIODevice::read_all() actually read all data

It used to only read the data it could get without blocking. Andreas says this
was intentional, but it's counterintuitive and no code that uses read_all()
actually expects it to return only a part of the data. So change it to always
read data until an EOF (or an error) is received.
This commit is contained in:
Sergey Bugaev 2020-01-17 21:51:23 +03:00 committed by Andreas Kling
parent cf04de188e
commit cee597a728

View file

@ -124,7 +124,7 @@ ByteBuffer CIODevice::read_all()
m_buffered_data.clear(); m_buffered_data.clear();
} }
while (can_read_from_fd()) { while (true) {
char read_buffer[4096]; char read_buffer[4096];
int nread = ::read(m_fd, read_buffer, sizeof(read_buffer)); int nread = ::read(m_fd, read_buffer, sizeof(read_buffer));
if (nread < 0) { if (nread < 0) {