[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 2/3] 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>
---
 src/logging/log_handler.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c
index cfadc69..c04f341 100644
--- a/src/logging/log_handler.c
+++ b/src/logging/log_handler.c
@@ -138,7 +138,7 @@ virLogHandlerGetLogFileFromWatch(virLogHandlerPtr handler,
 static void
 virLogHandlerDomainLogFileEvent(int watch,
                                 int fd,
-                                int events,
+                                int events G_GNUC_UNUSED,
                                 void *opaque)
 {
     virLogHandlerPtr handler = opaque;
@@ -169,14 +169,13 @@ virLogHandlerDomainLogFileEvent(int watch,
         virReportSystemError(errno, "%s",
                              _("Unable to read from log pipe"));
         goto error;
+    } else if (len == 0) {
+        goto error;
     }
 
     if (virRotatingFileWriterAppend(logfile->file, buf, len) != len)
         goto error;
 
-    if (events & VIR_EVENT_HANDLE_HANGUP)
-        goto error;
-
  cleanup:
     virObjectUnlock(handler);
     return;
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]