dlogutil_entry_s *const ret = lpd->entry;
lpd->entry = NULL;
+
+ /* Try to read a new entry immediately, so that the buffer will not become empty if possible.
+ * Since this is a nonblocking FD, we don't even have to make sure an entry is available.
+ * We ignore the result of the read. This is not an issue, because it can be either:
+ * 1. Number of bytes read, which is not useful to us,
+ * 2. Zero meaning EOF, which is returned in a different way (via the .eof method),
+ * 3. A negative number meaning error, which is not a big deal, since this is just
+ * an optimisation --- if the error repeats, we will see this when the .read method
+ * is called directly. */
+ logger_read(fdi);
+
return ret;
}
for (size_t i = 0; i < NELEMS(READS) + 15; ++i) {
assert(!ops_logger.has_log(&fdi));
+ fail_read = true;
assert(NULL == ops_logger.extract_entry(&fdi));
assert(NULL == ops_logger.peek_entry(&fdi));
assert(NULL == ops_logger.extract_entry(&fdi));
+ fail_read = false;
fail_malloc = !(rand() % 4) * 3;
ops_logger.read(&fdi);
if (!fail_malloc && i < NELEMS(READS) && READS[i] > sizeof(struct android_logger_entry)) {
const dlogutil_entry_s *const le = ops_logger.peek_entry(&fdi);
assert(le);
assert(le == ops_logger.peek_entry(&fdi));
+ fail_read = true;
assert(le == ops_logger.extract_entry(&fdi));
+ fail_read = false;
free((dlogutil_entry_s *) le);
}
fail_malloc = 0;
assert(!ops_logger.has_log(&fdi));
assert(NULL == ops_logger.peek_entry(&fdi));
+ fail_read = true;
assert(NULL == ops_logger.extract_entry(&fdi));
+ fail_read = false;
}
ops_logger.destroy(&fdi);