masaori335 commented on code in PR #13608:
URL: https://github.com/apache/trafficserver/pull/13608#discussion_r4118618476


##########
src/iocore/cache/unit_tests/test_CacheDir.cc:
##########
@@ -164,78 +164,157 @@ class CacheDirTest : public CacheInit
     memset(static_cast<void *>(&dir1), 0, sizeof(dir1));
     int s1, b1;
 
+    // Counted over the segment's rows: the chains are corrupt wherever this 
is used.
+    auto count_segment_entries = [&](int seg_index) {
+      Dir *seg_dir = stripe->directory.get_segment(seg_index);
+      int  used    = 0;
+      for (int b = 0; b < stripe->directory.buckets; b++) {
+        for (int l = 0; l < DIR_DEPTH; l++) {
+          if (dir_offset(dir_bucket_row(dir_bucket(b, seg_dir), l))) {
+            used++;
+          }
+        }
+      }
+      return used;
+    };
+
+    // Give a bucket a fresh chain long enough that a walk has to leave the 
bucket's own rows, then loop it.
+    auto corrupt_fresh_chain = [&]() {
+      for (int i = 0; i < 5; i++) {
+        stripe->directory.insert(&key, stripe, &dir1);
+      }
+      dir_corrupt_bucket(dir_bucket(b1, stripe->directory.get_segment(s1)), 
s1, stripe);

Review Comment:
   Fixed in 
[5548e9b](https://github.com/apache/trafficserver/pull/13608/commits/5548e9bb68398a368cd8d2a9b8b47163d25bf6ef)
 :  the helper now always picks a non-head entry.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to