0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-09 12:48:43 +00:00

Merge commit '0c59f7ff' into haugesund

This commit is contained in:
Maria Matejka 2022-03-09 09:13:55 +01:00
commit eeec9ddbf2
4 changed files with 31 additions and 4 deletions

View File

@ -37,9 +37,10 @@ const int lp_chunk_size = sizeof(struct lp_chunk);
struct linpool { struct linpool {
resource r; resource r;
byte *ptr, *end; byte *ptr, *end;
pool *p;
struct lp_chunk *first, *current; /* Normal (reusable) chunks */ struct lp_chunk *first, *current; /* Normal (reusable) chunks */
struct lp_chunk *first_large; /* Large chunks */ struct lp_chunk *first_large; /* Large chunks */
uint chunk_size, threshold, total, total_large; uint chunk_size, threshold, total:31, use_pages:1, total_large;
}; };
_Thread_local linpool *tmp_linpool; _Thread_local linpool *tmp_linpool;
@ -71,6 +72,13 @@ linpool
*lp_new(pool *p, uint blk) *lp_new(pool *p, uint blk)
{ {
linpool *m = ralloc(p, &lp_class); linpool *m = ralloc(p, &lp_class);
m->p = p;
if (!blk)
{
m->use_pages = 1;
blk = page_size - lp_chunk_size;
}
m->chunk_size = blk; m->chunk_size = blk;
m->threshold = 3*blk/4; m->threshold = 3*blk/4;
return m; return m;
@ -123,7 +131,11 @@ lp_alloc(linpool *m, uint size)
else else
{ {
/* Need to allocate a new chunk */ /* Need to allocate a new chunk */
if (m->use_pages)
c = alloc_page(m->p);
else
c = xmalloc(sizeof(struct lp_chunk) + m->chunk_size); c = xmalloc(sizeof(struct lp_chunk) + m->chunk_size);
m->total += m->chunk_size; m->total += m->chunk_size;
c->next = NULL; c->next = NULL;
c->size = m->chunk_size; c->size = m->chunk_size;
@ -260,6 +272,9 @@ lp_free(resource *r)
for(d=m->first; d; d = c) for(d=m->first; d; d = c)
{ {
c = d->next; c = d->next;
if (m->use_pages)
free_page(m->p, d);
else
xfree(d); xfree(d);
} }
for(d=m->first_large; d; d = c) for(d=m->first_large; d; d = c)

View File

@ -91,7 +91,7 @@ extern _Thread_local linpool *tmp_linpool; /* Temporary linpool autoflushed regu
extern const int lp_chunk_size; extern const int lp_chunk_size;
#define LP_GAS 1024 #define LP_GAS 1024
#define LP_GOOD_SIZE(x) (((x + LP_GAS - 1) & (~(LP_GAS - 1))) - lp_chunk_size) #define LP_GOOD_SIZE(x) (((x + LP_GAS - 1) & (~(LP_GAS - 1))) - lp_chunk_size)
#define lp_new_default(p) lp_new(p, LP_GOOD_SIZE(LP_GAS*4)) #define lp_new_default(p) lp_new(p, 0)
/* Slabs */ /* Slabs */

View File

@ -558,6 +558,9 @@ ospf_shutdown(struct proto *P)
} }
FIB_WALK_END; FIB_WALK_END;
if (tm_active(p->disp_timer))
tm_stop(p->disp_timer);
return PS_DOWN; return PS_DOWN;
} }

View File

@ -479,6 +479,14 @@ cli_err(sock *s, int err)
cli_free(s->data); cli_free(s->data);
} }
static void
cli_connect_err(sock *s UNUSED, int err)
{
ASSERT_DIE(err);
if (config->cli_debug)
log(L_INFO "Failed to accept CLI connection: %s", strerror(err));
}
static int static int
cli_connect(sock *s, uint size UNUSED) cli_connect(sock *s, uint size UNUSED)
{ {
@ -507,6 +515,7 @@ cli_init_unix(uid_t use_uid, gid_t use_gid)
s = cli_sk = sk_new(cli_pool); s = cli_sk = sk_new(cli_pool);
s->type = SK_UNIX_PASSIVE; s->type = SK_UNIX_PASSIVE;
s->rx_hook = cli_connect; s->rx_hook = cli_connect;
s->err_hook = cli_connect_err;
s->rbsize = 1024; s->rbsize = 1024;
s->fast_rx = 1; s->fast_rx = 1;