#include "util-debug.h"
static void ListRegions(StreamingBuffer *sb);
-#define REGION_MAX_GAP 250000
#define DUMP_REGIONS 0 // set to 1 to dump a visual representation of the regions list and sbb tree.
/* create the data range for the region, adding the max gap */
const uint64_t reg_o =
- r->stream_offset > REGION_MAX_GAP ? (r->stream_offset - REGION_MAX_GAP) : 0;
- const uint64_t reg_re = r->stream_offset + r->buf_size + REGION_MAX_GAP;
+ r->stream_offset > sb->cfg->region_gap ? (r->stream_offset - sb->cfg->region_gap) : 0;
+ const uint64_t reg_re = r->stream_offset + r->buf_size + sb->cfg->region_gap;
SCLogDebug("r %p: %" PRIu64 "/%" PRIu64 " - adjusted %" PRIu64 "/%" PRIu64, r, r->stream_offset,
r->stream_offset + r->buf_size, reg_o, reg_re);
/* check if data range intersects with region range */
static int StreamingBufferTest02(void)
{
- StreamingBufferConfig cfg = { 8, 24, 1, NULL, NULL, NULL };
+ StreamingBufferConfig cfg = { 8, 24, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL };
StreamingBuffer *sb = StreamingBufferInit(&cfg);
FAIL_IF(sb == NULL);
static int StreamingBufferTest03(void)
{
- StreamingBufferConfig cfg = { 8, 24, 1, NULL, NULL, NULL };
+ StreamingBufferConfig cfg = { 8, 24, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL };
StreamingBuffer *sb = StreamingBufferInit(&cfg);
FAIL_IF(sb == NULL);
static int StreamingBufferTest04(void)
{
- StreamingBufferConfig cfg = { 8, 16, 1, NULL, NULL, NULL };
+ StreamingBufferConfig cfg = { 8, 16, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL };
StreamingBuffer *sb = StreamingBufferInit(&cfg);
FAIL_IF(sb == NULL);
/** \test lots of gaps in block list */
static int StreamingBufferTest06(void)
{
- StreamingBufferConfig cfg = { 8, 16, 1, NULL, NULL, NULL };
+ StreamingBufferConfig cfg = { 8, 16, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL };
StreamingBuffer *sb = StreamingBufferInit(&cfg);
FAIL_IF(sb == NULL);
/** \test lots of gaps in block list */
static int StreamingBufferTest07(void)
{
- StreamingBufferConfig cfg = { 8, 16, 1, NULL, NULL, NULL };
+ StreamingBufferConfig cfg = { 8, 16, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL };
StreamingBuffer *sb = StreamingBufferInit(&cfg);
FAIL_IF(sb == NULL);
/** \test lots of gaps in block list */
static int StreamingBufferTest08(void)
{
- StreamingBufferConfig cfg = { 8, 16, 1, NULL, NULL, NULL };
+ StreamingBufferConfig cfg = { 8, 16, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL };
StreamingBuffer *sb = StreamingBufferInit(&cfg);
FAIL_IF(sb == NULL);
/** \test lots of gaps in block list */
static int StreamingBufferTest09(void)
{
- StreamingBufferConfig cfg = { 8, 16, 1, NULL, NULL, NULL };
+ StreamingBufferConfig cfg = { 8, 16, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL };
StreamingBuffer *sb = StreamingBufferInit(&cfg);
FAIL_IF(sb == NULL);
/** \test lots of gaps in block list */
static int StreamingBufferTest10(void)
{
- StreamingBufferConfig cfg = { 8, 16, 1, NULL, NULL, NULL };
+ StreamingBufferConfig cfg = { 8, 16, 1, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL };
StreamingBuffer *sb = StreamingBufferInit(&cfg);
FAIL_IF(sb == NULL);
#include "tree.h"
+#define STREAMING_BUFFER_REGION_GAP_DEFAULT 262144
+
typedef struct StreamingBufferConfig_ {
uint32_t buf_slide;
uint32_t buf_size;
uint16_t max_regions; /**< max concurrent memory regions. 0 means no limit. */
+ uint32_t region_gap; /**< max gap size before a new region will be created. */
void *(*Calloc)(size_t n, size_t size);
void *(*Realloc)(void *ptr, size_t orig_size, size_t size);
void (*Free)(void *ptr, size_t size);
#define STREAMING_BUFFER_CONFIG_INITIALIZER \
{ \
- 0, 0, 0, NULL, NULL, NULL, \
+ 0, 0, 0, STREAMING_BUFFER_REGION_GAP_DEFAULT, NULL, NULL, NULL, \
}
#define STREAMING_BUFFER_REGION_INIT \