mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-03 07:31:54 +00:00
Allocation from linpools and slabs requires the appropriate lock to be taken
This commit is contained in:
parent
010c26c296
commit
9f25dd79b8
@ -86,6 +86,7 @@ linpool
|
|||||||
void *
|
void *
|
||||||
lp_alloc(linpool *m, uint size)
|
lp_alloc(linpool *m, uint size)
|
||||||
{
|
{
|
||||||
|
ASSERT_DIE(DG_IS_LOCKED(resource_parent(&m->r)->domain));
|
||||||
byte *a = (byte *) BIRD_ALIGN((unsigned long) m->ptr, CPU_STRUCT_ALIGN);
|
byte *a = (byte *) BIRD_ALIGN((unsigned long) m->ptr, CPU_STRUCT_ALIGN);
|
||||||
byte *e = a + size;
|
byte *e = a + size;
|
||||||
|
|
||||||
@ -145,6 +146,7 @@ lp_alloc(linpool *m, uint size)
|
|||||||
void *
|
void *
|
||||||
lp_allocu(linpool *m, uint size)
|
lp_allocu(linpool *m, uint size)
|
||||||
{
|
{
|
||||||
|
ASSERT_DIE(DG_IS_LOCKED(resource_parent(&m->r)->domain));
|
||||||
byte *a = m->ptr;
|
byte *a = m->ptr;
|
||||||
byte *e = a + size;
|
byte *e = a + size;
|
||||||
|
|
||||||
@ -183,6 +185,7 @@ lp_allocz(linpool *m, uint size)
|
|||||||
void
|
void
|
||||||
lp_flush(linpool *m)
|
lp_flush(linpool *m)
|
||||||
{
|
{
|
||||||
|
ASSERT_DIE(DG_IS_LOCKED(resource_parent(&m->r)->domain));
|
||||||
struct lp_chunk *c;
|
struct lp_chunk *c;
|
||||||
|
|
||||||
/* Move ptr to the first chunk and free all other chunks */
|
/* Move ptr to the first chunk and free all other chunks */
|
||||||
@ -216,6 +219,7 @@ lp_flush(linpool *m)
|
|||||||
void
|
void
|
||||||
lp_save(linpool *m, lp_state *p)
|
lp_save(linpool *m, lp_state *p)
|
||||||
{
|
{
|
||||||
|
ASSERT_DIE(DG_IS_LOCKED(resource_parent(&m->r)->domain));
|
||||||
p->current = m->current;
|
p->current = m->current;
|
||||||
p->large = m->first_large;
|
p->large = m->first_large;
|
||||||
p->total_large = m->total_large;
|
p->total_large = m->total_large;
|
||||||
@ -236,6 +240,7 @@ void
|
|||||||
lp_restore(linpool *m, lp_state *p)
|
lp_restore(linpool *m, lp_state *p)
|
||||||
{
|
{
|
||||||
struct lp_chunk *c;
|
struct lp_chunk *c;
|
||||||
|
ASSERT_DIE(DG_IS_LOCKED(resource_parent(&m->r)->domain));
|
||||||
|
|
||||||
/* Move ptr to the saved pos and free all newer large chunks */
|
/* Move ptr to the saved pos and free all newer large chunks */
|
||||||
m->current = c = p->current ?: m->first;
|
m->current = c = p->current ?: m->first;
|
||||||
|
@ -189,13 +189,6 @@ pool_lookup(resource *P, unsigned long a)
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pool *
|
|
||||||
resource_parent(resource *r)
|
|
||||||
{
|
|
||||||
return SKIP_BACK(pool, inside, resource_enlisted(r));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rmove - move a resource
|
* rmove - move a resource
|
||||||
* @res: resource
|
* @res: resource
|
||||||
|
@ -76,6 +76,9 @@ void rp_free(pool *p); /* Free the whole pool */
|
|||||||
|
|
||||||
extern pool root_pool;
|
extern pool root_pool;
|
||||||
|
|
||||||
|
static inline pool *resource_parent(resource *r)
|
||||||
|
{ return SKIP_BACK(pool, inside, resource_enlisted(r)); }
|
||||||
|
|
||||||
/* Normal memory blocks */
|
/* Normal memory blocks */
|
||||||
|
|
||||||
void *mb_alloc(pool *, unsigned size);
|
void *mb_alloc(pool *, unsigned size);
|
||||||
|
@ -256,6 +256,7 @@ void *
|
|||||||
sl_alloc(slab *s)
|
sl_alloc(slab *s)
|
||||||
{
|
{
|
||||||
struct sl_head *h;
|
struct sl_head *h;
|
||||||
|
ASSERT_DIE(DG_IS_LOCKED(resource_parent(&s->r)->domain));
|
||||||
|
|
||||||
redo:
|
redo:
|
||||||
if (!(h = s->partial_heads.first))
|
if (!(h = s->partial_heads.first))
|
||||||
@ -331,6 +332,7 @@ sl_free(void *oo)
|
|||||||
{
|
{
|
||||||
struct sl_head *h = SL_GET_HEAD(oo);
|
struct sl_head *h = SL_GET_HEAD(oo);
|
||||||
struct slab *s = h->slab;
|
struct slab *s = h->slab;
|
||||||
|
ASSERT_DIE(DG_IS_LOCKED(resource_parent(&s->r)->domain));
|
||||||
|
|
||||||
#ifdef POISON
|
#ifdef POISON
|
||||||
memset(oo, 0xdb, s->data_size);
|
memset(oo, 0xdb, s->data_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user