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

Method insert_entry

src/proxy/hdrs/XPACK.cc:335–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333}
334
335const XpackLookupResult
336XpackDynamicTable::insert_entry(const char *name, size_t name_len, const char *value, size_t value_len)
337{
338 if (this->_max_entries == 0) {
339 return {UINT32_C(0), XpackLookupResult::MatchType::NONE};
340 }
341
342 // Make enough space to insert a new entry
343 uint64_t required_size = static_cast<uint64_t>(name_len) + static_cast<uint64_t>(value_len) + ADDITIONAL_32_BYTES;
344 if (required_size > this->_available) {
345 if (!this->_make_space(required_size - this->_available)) {
346 // We can't insert a new entry because some stream(s) refer an entry that need to be evicted or the header is too big to
347 // store. This is fine with HPACK, but not with QPACK.
348 return {UINT32_C(0), XpackLookupResult::MatchType::NONE};
349 }
350 }
351
352 // Insert
353 const char *wks = nullptr;
354 hdrtoken_tokenize(name, name_len, &wks);
355 this->_entries_head = this->_calc_index(this->_entries_head, 1);
356 this->_entries[this->_entries_head] = {
357 this->_entries_inserted++,
358 this->_storage.write(name, static_cast<uint32_t>(name_len), value, static_cast<uint32_t>(value_len)),
359 static_cast<uint32_t>(name_len),
360 static_cast<uint32_t>(value_len),
361 0,
362 wks};
363 this->_available -= required_size;
364
365 XPACKDbg("Insert Entry: entry=%u, index=%u, size=%zu", this->_entries_head, this->_entries_inserted - 1, name_len + value_len);
366 XPACKDbg("Available size: %u", this->_available);
367 return {this->_entries_inserted, value_len ? XpackLookupResult::MatchType::EXACT : XpackLookupResult::MatchType::NAME};
368}
369
370const XpackLookupResult
371XpackDynamicTable::insert_entry(const std::string_view name, const std::string_view value)

Callers 7

duplicate_entryMethod · 0.95
insertMethod · 0.45
add_header_fieldMethod · 0.45
_encode_headerMethod · 0.45
test_XPACK.ccFile · 0.45

Calls 6

_make_spaceMethod · 0.95
_calc_indexMethod · 0.95
hdrtoken_tokenizeFunction · 0.85
writeMethod · 0.45
dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected