logging: read all bytes on EOF in event handler

If writing side writes enough bytes to the pipe and closes writing
end then we got both VIR_EVENT_HANDLE_HANGUP and VIR_EVENT_HANDLE_READ
in handler. Currently in this situation handler reads 1024 bytes
and finish reading leaving unread data in pipe.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Nikolay Shirokovskiy 2020-09-24 15:47:09 +03:00
parent c6c2341570
commit 7c0e1a8631
1 changed files with 3 additions and 4 deletions

View File

@ -138,7 +138,7 @@ virLogHandlerGetLogFileFromWatch(virLogHandlerPtr handler,
static void static void
virLogHandlerDomainLogFileEvent(int watch, virLogHandlerDomainLogFileEvent(int watch,
int fd, int fd,
int events, int events G_GNUC_UNUSED,
void *opaque) void *opaque)
{ {
virLogHandlerPtr handler = opaque; virLogHandlerPtr handler = opaque;
@ -168,14 +168,13 @@ virLogHandlerDomainLogFileEvent(int watch,
virReportSystemError(errno, "%s", virReportSystemError(errno, "%s",
_("Unable to read from log pipe")); _("Unable to read from log pipe"));
goto error; goto error;
} else if (len == 0) {
goto error;
} }
if (virRotatingFileWriterAppend(logfile->file, buf, len) != len) if (virRotatingFileWriterAppend(logfile->file, buf, len) != len)
goto error; goto error;
if (events & VIR_EVENT_HANDLE_HANGUP)
goto error;
cleanup: cleanup:
virObjectUnlock(handler); virObjectUnlock(handler);
return; return;