MINOR: trace: add allocation of buffer-sized trace buffers

This will be needed so that we can implement protocol decoders which will
have to emit their contents into such a buffer.
This commit is contained in:
Willy Tarreau 2019-08-19 15:55:34 +02:00
parent 4151c753fc
commit 88ebd4050e
2 changed files with 18 additions and 0 deletions

View File

@ -32,6 +32,7 @@
#include <types/trace.h>
extern struct list trace_sources;
extern THREAD_LOCAL struct buffer trace_buf;
/* registers trace source <source>. Modifies the list element!
* The {start,pause,stop,report} events are not changed so the source may

View File

@ -27,7 +27,24 @@
#include <proto/trace.h>
struct list trace_sources = LIST_HEAD_INIT(trace_sources);
THREAD_LOCAL struct buffer trace_buf = { };
/* allocates the trace buffers. Returns 0 in case of failure. It is safe to
* call to call this function multiple times if the size changes.
*/
static int alloc_trace_buffers_per_thread()
{
chunk_init(&trace_buf, my_realloc2(trace_buf.area, global.tune.bufsize), global.tune.bufsize);
return !!trash.area;
}
static void free_trace_buffers_per_thread()
{
chunk_destroy(&trace_buf);
}
REGISTER_PER_THREAD_ALLOC(alloc_trace_buffers_per_thread);
REGISTER_PER_THREAD_FREE(free_trace_buffers_per_thread);
/*
* Local variables:
* c-indent-level: 8