2 #include <aura/private.h>
5 void aura_buffer_internal_free(
struct aura_buffer *buf);
12 static struct aura_buffer *fetch_buffer_from_pool(
struct aura_node *nd,
16 list_for_each_safe(pos, tmp, &nd->buffer_pool)
19 if (buf->
size >= size) {
21 nd->num_buffers_in_pool--;
43 act_size += nd->tr->buffer_overhead;
45 #ifdef AURA_USE_BUFFER_POOL
47 ret = fetch_buffer_from_pool(nd, act_size);
53 if (!nd->tr->buffer_request) {
57 BUG(nd,
"FATAL: malloc() failed");
58 ret->
data = &data[
sizeof(*ret)];
60 ret = nd->tr->buffer_request(nd, act_size);
62 BUG(nd,
"FATAL: buffer allocation by transport failed");
66 ret->
magic = AURA_BUFFER_MAGIC_ID;
82 #ifdef AURA_USE_BUFFER_POOL
83 struct aura_node *nd = buf->
owner;
84 if (buf->
magic != AURA_BUFFER_MAGIC_ID)
86 "FATAL: Attempting to release a buffer with invalid magic OR double free an aura_buffer");
88 list_add(&buf->
qentry, &nd->buffer_pool);
89 nd->num_buffers_in_pool++;
102 struct aura_node *nd = buf->
owner;
103 if (buf->
magic != AURA_BUFFER_MAGIC_ID)
105 "FATAL: Attempting to destroy a buffer with invalid magic OR double free an aura_buffer");
108 if (nd && nd->tr->buffer_release)
109 nd->tr->buffer_release(buf);
129 list_for_each_entry_safe_reverse(pos, tmp, &nd->buffer_pool,
qentry)
132 || (numdrop-- && nd->num_buffers_in_pool > threshold)) {
134 nd->num_buffers_in_pool--;
152 slog(0, SLOG_DEBUG,
"!");
165 nd->gc_threshold = threshold;
struct aura_buffer * aura_buffer_request(struct aura_node *nd, int size)
void aura_bufferpool_set_gc_threshold(struct aura_node *nd, int threshold)
void aura_bufferpool_gc(struct aura_node *nd, int numdrop, int threshold)
void aura_bufferpool_preheat(struct aura_node *nd, int size, int count)
static void aura_buffer_rewind(struct aura_buffer *buf)
void aura_buffer_release(struct aura_buffer *buf)
void aura_buffer_destroy(struct aura_buffer *buf)