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

Method addBytes

plugins/cache_promote/lru_policy.cc:220–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220void
221LRUPolicy::addBytes(TSHttpTxn txnp)
222{
223 LRUHash *hash = static_cast<LRUHash *>(TSUserArgGet(txnp, TXN_ARG_IDX));
224
225 if (hash) {
226 LRUMap::iterator map_it;
227
228 // We have to hold the lock across all list and hash access / updates
229 TSMutexLock(_lock);
230 map_it = _map.find(hash);
231 if (_map.end() != map_it) {
232 TSMBuffer resp;
233 TSMLoc resp_hdr;
234
235 if (TS_SUCCESS == TSHttpTxnServerRespGet(txnp, &resp, &resp_hdr)) {
236 TSMLoc field_loc = TSMimeHdrFieldFind(resp, resp_hdr, TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH);
237
238 if (field_loc) {
239 auto &[val_key, val_hits, val_bytes] = *(map_it->second);
240 int64_t cl = TSMimeHdrFieldValueInt64Get(resp, resp_hdr, field_loc, -1);
241
242 // This is because compilers before gcc 8 aren't smart enough to ignore the unused structured bindings
243 (void)val_key, (void)val_hits;
244
245 val_bytes += cl;
246 DBG("Added %" PRId64 " bytes for LRU entry", cl);
247 TSHandleMLocRelease(resp, resp_hdr, field_loc);
248 }
249 TSHandleMLocRelease(resp, TS_NULL_MLOC, resp_hdr);
250 }
251 }
252 TSMutexUnlock(_lock);
253 }
254}
255
256bool
257LRUPolicy::stats_add(const char *remap_id)

Callers 1

cont_handle_policyFunction · 0.45

Calls 9

TSUserArgGetFunction · 0.85
TSMutexLockFunction · 0.85
TSHttpTxnServerRespGetFunction · 0.85
TSMimeHdrFieldFindFunction · 0.85
TSHandleMLocReleaseFunction · 0.85
TSMutexUnlockFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected