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

Function dir_bucket_loop_check

src/iocore/cache/CacheDir.cc:188–215  ·  view source on GitHub ↗

return value 1 means no loop zero indicates loop

Source from the content-addressed store, hash-verified

186// return value 1 means no loop
187// zero indicates loop
188int
189dir_bucket_loop_check(Dir *start_dir, Dir *seg)
190{
191 if (start_dir == nullptr) {
192 return 1;
193 }
194
195 Dir *p1 = start_dir;
196 Dir *p2 = start_dir;
197
198 while (p2) {
199 // p1 moves by one entry per iteration
200 ink_assert(p1);
201 p1 = next_dir(p1, seg);
202 // p2 moves by two entries per iteration
203 p2 = next_dir(p2, seg);
204 if (p2) {
205 p2 = next_dir(p2, seg);
206 } else {
207 return 1;
208 }
209
210 if (p2 == p1) {
211 return 0; // we have a loop
212 }
213 }
214 return 1;
215}
216
217// adds all the directory entries
218// in a segment to the segment freelist

Callers 2

dir_bucket_loop_fixFunction · 0.70
check_dirFunction · 0.70

Calls 1

next_dirFunction · 0.70

Tested by

no test coverage detected