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: ...@@ -108,9 +108,7 @@ public:
return _start_index + (_add_times - *v) - 1; return _start_index + (_add_times - *v) - 1;
} }
bool empty() const { return (size() == 0); } bool empty() const { return _size == 0; }
size_t size() const { return _size; }
size_t max_size() const { return _max_size; }
int start_index() const { return _start_index; } int start_index() const { return _start_index; }
int end_index() const { return start_index() + _header_queue.size(); } int end_index() const { return start_index() + _header_queue.size(); }
...@@ -123,7 +121,7 @@ public: ...@@ -123,7 +121,7 @@ public:
DCHECK(!empty()); DCHECK(!empty());
const Header* h = _header_queue.top(); const Header* h = _header_queue.top();
const size_t entry_size = HeaderSize(*h); 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(); const uint64_t id = _add_times - _header_queue.size();
if (_need_indexes) { if (_need_indexes) {
RemoveHeaderFromIndexes(*h, id); RemoveHeaderFromIndexes(*h, id);
...@@ -133,12 +131,14 @@ public: ...@@ -133,12 +131,14 @@ public:
} }
void RemoveHeaderFromIndexes(const Header& h, uint64_t expected_id) { void RemoveHeaderFromIndexes(const Header& h, uint64_t expected_id) {
if (!h.value.empty()) {
const uint64_t* v = _header_index.seek(h); const uint64_t* v = _header_index.seek(h);
DCHECK(v); DCHECK(v);
if (*v == expected_id) { if (*v == expected_id) {
_header_index.erase(h); _header_index.erase(h);
} }
v = _name_index.seek(h.name); }
const uint64_t* v = _name_index.seek(h.name);
DCHECK(v); DCHECK(v);
if (*v == expected_id) { if (*v == expected_id) {
_name_index.erase(h.name); _name_index.erase(h.name);
...@@ -153,7 +153,7 @@ public: ...@@ -153,7 +153,7 @@ public:
PopHeader(); PopHeader();
} }
if (entry_size > max_size()) { if (entry_size > _max_size) {
// https://tools.ietf.org/html/rfc7541#section-4.1 // https://tools.ietf.org/html/rfc7541#section-4.1
// If this header is larger than the max size, clear the table only. // If this header is larger than the max size, clear the table only.
DCHECK(empty()); DCHECK(empty());
...@@ -175,8 +175,8 @@ public: ...@@ -175,8 +175,8 @@ public:
} }
void ResetMaxSize(size_t new_max_size) { void ResetMaxSize(size_t new_max_size) {
LOG(INFO) << this << ".size=" << size() << " new_max_size=" << new_max_size LOG(INFO) << this << ".size=" << _size << " new_max_size=" << new_max_size
<< " max_size=" << max_size(); << " max_size=" << _max_size;
if (new_max_size > _max_size) { if (new_max_size > _max_size) {
//LOG(ERROR) << "Invalid new_max_size=" << new_max_size; //LOG(ERROR) << "Invalid new_max_size=" << new_max_size;
//return -1; //return -1;
...@@ -185,7 +185,7 @@ public: ...@@ -185,7 +185,7 @@ public:
} }
if (new_max_size < _max_size) { if (new_max_size < _max_size) {
_max_size = new_max_size; _max_size = new_max_size;
while (size() > max_size()) { while (_size > _max_size) {
PopHeader(); 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