Commit b5900a38 authored by gejun's avatar gejun

Only remove from _header_index when value is non-empty

parent 6b83a5d8
......@@ -108,9 +108,7 @@ public:
return _start_index + (_add_times - *v) - 1;
}
bool empty() const { return (size() == 0); }
size_t size() const { return _size; }
size_t max_size() const { return _max_size; }
bool empty() const { return _size == 0; }
int start_index() const { return _start_index; }
int end_index() const { return start_index() + _header_queue.size(); }
......@@ -123,7 +121,7 @@ public:
DCHECK(!empty());
const Header* h = _header_queue.top();
const size_t entry_size = HeaderSize(*h);
DCHECK_LE(entry_size, size());
DCHECK_LE(entry_size, _size);
const uint64_t id = _add_times - _header_queue.size();
if (_need_indexes) {
RemoveHeaderFromIndexes(*h, id);
......@@ -133,12 +131,14 @@ public:
}
void RemoveHeaderFromIndexes(const Header& h, uint64_t expected_id) {
const uint64_t* v = _header_index.seek(h);
DCHECK(v);
if (*v == expected_id) {
_header_index.erase(h);
if (!h.value.empty()) {
const uint64_t* v = _header_index.seek(h);
DCHECK(v);
if (*v == expected_id) {
_header_index.erase(h);
}
}
v = _name_index.seek(h.name);
const uint64_t* v = _name_index.seek(h.name);
DCHECK(v);
if (*v == expected_id) {
_name_index.erase(h.name);
......@@ -153,7 +153,7 @@ public:
PopHeader();
}
if (entry_size > max_size()) {
if (entry_size > _max_size) {
// https://tools.ietf.org/html/rfc7541#section-4.1
// If this header is larger than the max size, clear the table only.
DCHECK(empty());
......@@ -175,8 +175,8 @@ public:
}
void ResetMaxSize(size_t new_max_size) {
LOG(INFO) << this << ".size=" << size() << " new_max_size=" << new_max_size
<< " max_size=" << max_size();
LOG(INFO) << this << ".size=" << _size << " new_max_size=" << new_max_size
<< " max_size=" << _max_size;
if (new_max_size > _max_size) {
//LOG(ERROR) << "Invalid new_max_size=" << new_max_size;
//return -1;
......@@ -185,7 +185,7 @@ public:
}
if (new_max_size < _max_size) {
_max_size = new_max_size;
while (size() > max_size()) {
while (_size > _max_size) {
PopHeader();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment