This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 5df027fa67 Fix cache test reenable loop in VC_EVENT_READ_READY handler
(#12712)
5df027fa67 is described below
commit 5df027fa67f2ecebbd31e54cd13c95584009698a
Author: Bryan Call <[email protected]>
AuthorDate: Wed Dec 10 09:40:26 2025 -0800
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.
---
src/iocore/cache/unit_tests/main.cc | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/iocore/cache/unit_tests/main.cc
b/src/iocore/cache/unit_tests/main.cc
index e01dd8463a..369b0572b4 100644
--- a/src/iocore/cache/unit_tests/main.cc
+++ b/src/iocore/cache/unit_tests/main.cc
@@ -319,19 +319,23 @@ CacheReadTest::read_event(int event, void *e)
this->process_event(event);
break;
case VC_EVENT_READ_READY: {
+ // Consume all available data blocks and validate against expected data
while (this->_reader->block_read_avail()) {
auto str = this->_reader->block_read_view();
if (memcmp(str.data(), this->_cursor, str.size()) == 0) {
this->_reader->consume(str.size());
this->_cursor += str.size();
- this->process_event(event);
} else {
+ // Data corruption detected - fail the test immediately
CHECK(false);
this->close();
TEST_DONE();
- break;
+ return 0;
}
}
+ // After consuming all available data, reenable the VIO to signal
readiness for more.
+ // This should only be called once per VC_EVENT_READ_READY event, not
per-block.
+ this->process_event(event);
break;
}
case VC_EVENT_ERROR: