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

Method _make_space

src/proxy/hdrs/XPACK.cc:499–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499bool
500XpackDynamicTable::_make_space(uint64_t extra_space_needed)
501{
502 uint32_t freed = 0;
503 uint32_t tail = this->_entries_tail;
504
505 // Check to see if we need more space and that we have entries to evict
506 while (extra_space_needed > freed && this->_entries_head != tail) {
507 tail = this->_calc_index(tail, 1); // Move to the next entry
508
509 if (this->_entries[tail].ref_count) {
510 break;
511 }
512 freed += this->_entries[tail].name_len + this->_entries[tail].value_len + ADDITIONAL_32_BYTES;
513 }
514
515 // Evict
516 if (freed > 0) {
517 XPACKDbg("Evict entries: from %u to %u", this->_entries[this->_calc_index(this->_entries_tail, 1)].index,
518 this->_entries[tail - 1].index);
519 this->_available += freed;
520 this->_entries_tail = tail;
521
522 XPACKDbg("Available size: %u", this->_available);
523 }
524
525 return freed >= extra_space_needed;
526}
527
528uint32_t
529XpackDynamicTable::_calc_index(uint32_t base, int64_t offset) const

Callers 2

insert_entryMethod · 0.95
update_maximum_sizeMethod · 0.95

Calls 1

_calc_indexMethod · 0.95

Tested by

no test coverage detected