MCPcopy Create free account
hub / github.com/apache/trafficserver / dir_bucket_loop_check

Function dir_bucket_loop_check

src/traffic_cache_tool/CacheDefs.cc:641–668  ·  view source on GitHub ↗

return value 1 means no loop zero indicates loop

Source from the content-addressed store, hash-verified

639// return value 1 means no loop
640// zero indicates loop
641int
642dir_bucket_loop_check(CacheDirEntry *start_dir, CacheDirEntry *seg)
643{
644 if (start_dir == nullptr) {
645 return 1;
646 }
647
648 CacheDirEntry *p1 = start_dir;
649 CacheDirEntry *p2 = start_dir;
650
651 while (p2) {
652 // p1 moves by one entry per iteration
653 ink_assert(p1);
654 p1 = next_dir(p1, seg);
655 // p2 moves by two entries per iteration
656 p2 = next_dir(p2, seg);
657 if (p2) {
658 p2 = next_dir(p2, seg);
659 } else {
660 return 1;
661 }
662
663 if (p2 == p1) {
664 return 0; // we have a loop
665 }
666 }
667 return 1;
668}
669#endif
670
671int

Callers

nothing calls this directly

Calls 1

next_dirFunction · 0.70

Tested by

no test coverage detected