Fix incorrect reading logic and EAGAIN handling
This is one of the issues raised by #4410
This commit is contained in:
parent
be4659097c
commit
d2e2caaae6
|
@ -176,9 +176,12 @@ FDWatcher make_reader(int fd, String& contents, OnClose&& on_close)
|
|||
char buffer[1024];
|
||||
while (fd_readable(fd))
|
||||
{
|
||||
size_t size = ::read(fd, buffer, sizeof(buffer));
|
||||
ssize_t size = ::read(fd, buffer, sizeof(buffer));
|
||||
if (size <= 0)
|
||||
{
|
||||
if (size < 0 and errno == EAGAIN)
|
||||
continue; // try again
|
||||
|
||||
watcher.disable();
|
||||
on_close();
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue
Block a user