Fix missing logs when a dlogutil pipe gets clogged 15/217215/3
authorMichal Bloch <m.bloch@samsung.com>
Thu, 7 Nov 2019 12:24:09 +0000 (13:24 +0100)
committerMichal Bloch <m.bloch@partner.samsung.com>
Tue, 12 Nov 2019 17:20:55 +0000 (17:20 +0000)
Change-Id: I44e5c53401abc03605fdc9a0c15e5611742d31a1
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/logger/logger.c

index fbb19a5..ad4071a 100644 (file)
@@ -661,9 +661,12 @@ static int reader_print_out_single_log(struct reader *reader, const struct dlogu
 
        int r = write(reader->file.path ? reader->file.fd : reader->fd_entity.fd, dlogutil_entry, dlogutil_entry->len);
        if (r < 0) {
-               if (errno == EPIPE)
+               if (errno != EAGAIN)
                        return 1;
-               return -1;
+
+               /* The pipe is just clogged, this is not an actual error.
+                * We own the entry so it needs to be saved for later. */
+               r = 0;
        }
 
        reader->file.size += r;
@@ -696,7 +699,7 @@ int print_out_logs(struct reader *reader)
        if (reader->partial_log_size) {
                r = write(reader->fd_entity.fd, reader->partial_log, reader->partial_log_size);
                if (r <= 0)
-                       return ret;
+                       return r != 0 && errno != EAGAIN;
 
                if (r < reader->partial_log_size) {
                        reader->partial_log_size -= r;