Assert that the logger devices don't end 73/242873/1
authorMateusz Majewski <m.majewski2@samsung.com>
Tue, 1 Sep 2020 10:41:28 +0000 (12:41 +0200)
committerMateusz Majewski <m.majewski2@samsung.com>
Tue, 1 Sep 2020 11:22:08 +0000 (13:22 +0200)
Change-Id: Ib8abd22294360784158a75d49af127019922872a

src/libdlogutil/fdi_logger.c
src/tests/fdi_logger_wrap.c

index a1d1bec..ce2494e 100644 (file)
@@ -222,6 +222,7 @@ static int logger_read(struct fd_info *fdi)
                assert(lpd->log_len != UNLIMITED_LOG_LEN);
                while (lpd->log_len > 0) {
                        int r = read(fdi->fd, buff, sizeof buff);
+                       assert(r != 0);
                        if (r < 0) {
                                /* Logs arriving into the buffer can overwrite existing logs,
                                 * but this doesn't update the total length on our side. This
@@ -247,6 +248,7 @@ static int logger_read(struct fd_info *fdi)
 
        assert(!lpd->monitor);
        int r = read(fdi->fd, buff, sizeof buff);
+       assert(r != 0);
        if (r < 0) {
                if (lpd->log_len > 0 && lpd->log_len != UNLIMITED_LOG_LEN) {
                        // See above
index 4ca5a27..7cb8d79 100644 (file)
@@ -94,8 +94,10 @@ ssize_t __wrap_read(int fd, void *buf, size_t count)
                return -1;
        }
 
-       if (read_cnt == NELEMS(READS))
-               return 0;
+       if (read_cnt == NELEMS(READS)) {
+               errno = EAGAIN;
+               return -1;
+       }
 
        const size_t current_read = READS[read_cnt++];
        assert(current_read < count);