mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 15:18:20 +00:00
Reorganize reassembly data structures
Started by factoring some details into a new DataBlockList class to at least make it more clear where modifications occur. More abstractions likely to happen later as I experiment with alternate data structures aimed at improving worse-case scenarios.
This commit is contained in:
parent
395c685da1
commit
b19c8fad7a
8 changed files with 343 additions and 285 deletions
|
@ -26,6 +26,8 @@ uint64_t FileReassembler::Flush()
|
|||
if ( flushing )
|
||||
return 0;
|
||||
|
||||
auto last_block = block_list.Tail();
|
||||
|
||||
if ( last_block )
|
||||
{
|
||||
// This is expected to call back into FileReassembler::Undelivered().
|
||||
|
@ -50,13 +52,14 @@ uint64_t FileReassembler::FlushTo(uint64_t sequence)
|
|||
return rval;
|
||||
}
|
||||
|
||||
void FileReassembler::BlockInserted(DataBlock* start_block)
|
||||
void FileReassembler::BlockInserted(const DataBlock* start_block)
|
||||
{
|
||||
if ( start_block->seq > last_reassem_seq ||
|
||||
start_block->upper <= last_reassem_seq )
|
||||
return;
|
||||
|
||||
for ( DataBlock* b = start_block;
|
||||
// TODO: better way to iterate ?
|
||||
for ( auto b = start_block;
|
||||
b && b->seq <= last_reassem_seq; b = b->next )
|
||||
{
|
||||
if ( b->seq == last_reassem_seq )
|
||||
|
@ -74,8 +77,9 @@ void FileReassembler::BlockInserted(DataBlock* start_block)
|
|||
void FileReassembler::Undelivered(uint64_t up_to_seq)
|
||||
{
|
||||
// If we have blocks that begin below up_to_seq, deliver them.
|
||||
DataBlock* b = blocks;
|
||||
const DataBlock* b = block_list.Head();
|
||||
|
||||
// TODO: better way to iterate ?
|
||||
while ( b )
|
||||
{
|
||||
if ( b->seq < last_reassem_seq )
|
||||
|
@ -96,7 +100,7 @@ void FileReassembler::Undelivered(uint64_t up_to_seq)
|
|||
BlockInserted(b);
|
||||
// Inserting a block may cause trimming of what's buffered,
|
||||
// so have to assume 'b' is invalid, hence re-assign to start.
|
||||
b = blocks;
|
||||
b = block_list.Head();
|
||||
}
|
||||
|
||||
if ( up_to_seq > last_reassem_seq )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue