| 218 | } |
| 219 | |
| 220 | void |
| 221 | LRUPolicy::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 | |
| 256 | bool |
| 257 | LRUPolicy::stats_add(const char *remap_id) |
no test coverage detected