From 385b3ea3956aefc2868cdd838fc0a90f1d8a7857 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 30 Nov 2021 18:16:49 +0100 Subject: For safer memory allocations, resources are bound to loops. Also all loops have their basic resource pool for allocations which are auto-freed when the loop is stopping. --- proto/bfd/bfd.c | 8 +++----- proto/bfd/bfd.h | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'proto/bfd') diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c index dd3488d4..c9b12aa1 100644 --- a/proto/bfd/bfd.c +++ b/proto/bfd/bfd.c @@ -452,8 +452,8 @@ bfd_add_session(struct bfd_proto *p, ip_addr addr, ip_addr local, struct iface * s->passive = s->cf.passive; s->tx_csn = random_u32(); - s->tx_timer = tm_new_init(p->tpool, bfd_tx_timer_hook, s, 0, 0); - s->hold_timer = tm_new_init(p->tpool, bfd_hold_timer_hook, s, 0, 0); + s->tx_timer = tm_new_init(p->p.pool, bfd_tx_timer_hook, s, 0, 0); + s->hold_timer = tm_new_init(p->p.pool, bfd_hold_timer_hook, s, 0, 0); bfd_session_update_tx_interval(s); bfd_session_control_tx_timer(s, 1); @@ -581,7 +581,7 @@ bfd_get_iface(struct bfd_proto *p, ip_addr local, struct iface *iface) struct bfd_config *cf = (struct bfd_config *) (p->p.cf); struct bfd_iface_config *ic = bfd_find_iface_config(cf, iface); - ifa = mb_allocz(p->tpool, sizeof(struct bfd_iface)); + ifa = mb_allocz(p->p.pool, sizeof(struct bfd_iface)); ifa->local = local; ifa->iface = iface; ifa->cf = ic; @@ -1062,8 +1062,6 @@ bfd_start(struct proto *P) pthread_spin_init(&p->lock, PTHREAD_PROCESS_PRIVATE); - p->tpool = rp_new(P->pool, "BFD loop pool"); - p->session_slab = sl_new(P->pool, sizeof(struct bfd_session)); HASH_INIT(p->session_hash_id, P->pool, 8); HASH_INIT(p->session_hash_ip, P->pool, 8); diff --git a/proto/bfd/bfd.h b/proto/bfd/bfd.h index 8430064b..475b3a11 100644 --- a/proto/bfd/bfd.h +++ b/proto/bfd/bfd.h @@ -90,8 +90,6 @@ struct bfd_proto pthread_spinlock_t lock; - pool *tpool; - node bfd_node; slab *session_slab; -- cgit v1.2.3