Skip to content

Commit 5df027f

Browse files
authored
Fix cache test reenable loop in VC_EVENT_READ_READY handler (#12712)
Move process_event() call outside the while loop that consumes data blocks. The original code was calling reenable() for every block of data, which is incorrect. The correct pattern (as shown in CacheTestSM) is to consume all available data, then call reenable() once to signal readiness for more. This fixes the flaky test_cache_Populated_Cache test that was aborting due to excessive reenables when reading from a populated cache with many blocks.
1 parent bd851ac commit 5df027f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/iocore/cache/unit_tests/main.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,19 +319,23 @@ CacheReadTest::read_event(int event, void *e)
319319
this->process_event(event);
320320
break;
321321
case VC_EVENT_READ_READY: {
322+
// Consume all available data blocks and validate against expected data
322323
while (this->_reader->block_read_avail()) {
323324
auto str = this->_reader->block_read_view();
324325
if (memcmp(str.data(), this->_cursor, str.size()) == 0) {
325326
this->_reader->consume(str.size());
326327
this->_cursor += str.size();
327-
this->process_event(event);
328328
} else {
329+
// Data corruption detected - fail the test immediately
329330
CHECK(false);
330331
this->close();
331332
TEST_DONE();
332-
break;
333+
return 0;
333334
}
334335
}
336+
// After consuming all available data, reenable the VIO to signal readiness for more.
337+
// This should only be called once per VC_EVENT_READ_READY event, not per-block.
338+
this->process_event(event);
335339
break;
336340
}
337341
case VC_EVENT_ERROR:

0 commit comments

Comments
 (0)