unsigned Http2FlowData::inspector_id = 0;
Http2Stream::~Http2Stream() = default;
+HpackDynamicTable::HpackDynamicTable(Http2FlowData* flow_data) :
+ session_data(flow_data) {}
HpackDynamicTable::~HpackDynamicTable() = default;
Http2DataCutter::Http2DataCutter(Http2FlowData* _session_data, HttpCommon::SourceId src_id) :
session_data(_session_data), source_id(src_id) { }
#endif
#include "http2_hpack_dynamic_table.h"
-#include "http2_module.h"
#include <cstring>
+#include "http2_flow_data.h"
#include "http2_hpack_table.h"
+#include "http2_module.h"
using namespace Http2Enums;
+HpackDynamicTable::HpackDynamicTable(Http2FlowData* flow_data) :
+ session_data(flow_data)
+{
+ session_data->update_allocations( ARRAY_CAPACITY * sizeof(HpackTableEntry*) +
+ TABLE_MEMORY_TRACKING_INCREMENT);
+ table_memory_allocated = TABLE_MEMORY_TRACKING_INCREMENT;
+}
+
+
HpackDynamicTable::~HpackDynamicTable()
{
- for (std::vector<HpackTableEntry*>::iterator it = circular_buf.begin();
- it != circular_buf.end(); ++it)
+ for (uint32_t i = 0, indx = start; i < num_entries; i++)
{
- delete *it;
+ delete circular_buf[indx];
+ indx = (indx + 1) % ARRAY_CAPACITY;
+ }
+ session_data->update_deallocations( ARRAY_CAPACITY * sizeof(HpackTableEntry*) +
+ TABLE_MEMORY_TRACKING_INCREMENT );
+
+ while (table_memory_allocated > TABLE_MEMORY_TRACKING_INCREMENT)
+ {
+ session_data->update_deallocations(TABLE_MEMORY_TRACKING_INCREMENT);
+ table_memory_allocated -= TABLE_MEMORY_TRACKING_INCREMENT;
}
}
Http2Module::increment_peg_counts(PEG_MAX_TABLE_ENTRIES);
rfc_table_size += new_entry_size;
+ while (rfc_table_size > table_memory_allocated)
+ {
+ session_data->update_allocations(TABLE_MEMORY_TRACKING_INCREMENT);
+ table_memory_allocated += TABLE_MEMORY_TRACKING_INCREMENT;
+ }
+
return true;
}
#include <vector>
struct HpackTableEntry;
+class Http2FlowData;
class HpackDynamicTable
{
public:
// FIXIT-P This array can be optimized to start smaller and grow on demand
- HpackDynamicTable() : circular_buf(ARRAY_CAPACITY, nullptr) {}
+ HpackDynamicTable(Http2FlowData* flow_data);
~HpackDynamicTable();
const HpackTableEntry* get_entry(uint32_t index) const;
bool add_entry(const Field& name, const Field& value);
const static uint32_t DEFAULT_MAX_SIZE = 4096;
const static uint32_t ARRAY_CAPACITY = 512;
+ const static uint32_t TABLE_MEMORY_TRACKING_INCREMENT = 500;
uint32_t max_size = DEFAULT_MAX_SIZE;
uint32_t start = 0;
uint32_t num_entries = 0;
uint32_t rfc_table_size = 0;
- std::vector<HpackTableEntry*> circular_buf;
+ HpackTableEntry* circular_buf[ARRAY_CAPACITY] = {0};
+ Http2FlowData* const session_data;
+ uint32_t table_memory_allocated;
void prune_to_size(uint32_t new_max_size);
};
{
public:
HpackIndexTable(Http2FlowData* flow_data, HttpCommon::SourceId src_id) :
- session_data(flow_data), source_id(src_id) { }
+ dynamic_table(flow_data), session_data(flow_data), source_id(src_id)
+ { }
const HpackTableEntry* lookup(uint64_t index) const;
bool add_index(const Field& name, const Field& value);
bool hpack_table_size_update(const uint32_t size);