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

Method uniqueAcquire

plugins/prefetch/fetch.cc:290–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290bool
291BgFetchState::uniqueAcquire(const String &url)
292{
293 bool permitted = true;
294 bool throttled = false;
295 size_t cachedCounter = 0;
296
297 TSMutexLock(_lock);
298 if (0 == _concurrentFetchesMax || _concurrentFetches < _concurrentFetchesMax) {
299 permitted = _unique->acquire(url);
300 if (permitted) {
301 cachedCounter = ++_concurrentFetches;
302 }
303 } else {
304 throttled = true;
305 }
306 TSMutexUnlock(_lock);
307
308 /* Update the metrics, no need to lock? */
309 if (throttled) {
310 incrementMetric(FETCH_THROTTLED);
311 }
312
313 if (permitted && !throttled) {
314 incrementMetric(FETCH_UNIQUE_YES);
315 incrementMetric(FETCH_TOTAL);
316 setMetric(FETCH_ACTIVE, cachedCounter);
317 } else {
318 incrementMetric(FETCH_UNIQUE_NO);
319 }
320
321 return permitted;
322}
323
324bool
325BgFetchState::uniqueRelease(const String &url)

Callers 2

contHandleFetchFunction · 0.80
initMethod · 0.80

Calls 3

TSMutexLockFunction · 0.85
TSMutexUnlockFunction · 0.85
acquireMethod · 0.45

Tested by

no test coverage detected