From 1141ce4e2d924f29e6e31ccf5e325f870c8895dd Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Thu, 20 Apr 2023 21:08:38 +0200 Subject: Resource pool closing has its dedicated function --- conf/conf.c | 2 +- lib/resource.c | 4 ++-- lib/resource.h | 7 +++++++ nest/cli.c | 2 +- nest/proto.c | 2 +- nest/rt-show.c | 2 +- nest/rt-table.c | 2 +- proto/babel/babel.c | 2 +- proto/bgp/attrs.c | 2 +- proto/mrt/mrt.c | 2 +- proto/ospf/iface.c | 2 +- proto/ospf/neighbor.c | 2 +- proto/radv/radv.c | 2 +- sysdep/unix/io-loop.c | 8 ++++---- 14 files changed, 24 insertions(+), 17 deletions(-) diff --git a/conf/conf.c b/conf/conf.c index daac85c1..2cfe7b15 100644 --- a/conf/conf.c +++ b/conf/conf.c @@ -200,7 +200,7 @@ config_free(struct config *c) ASSERT(!c->obstacle_count); - rfree(c->pool); + rp_free(c->pool); } /** diff --git a/lib/resource.c b/lib/resource.c index 94b8d019..0006bc8d 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -298,7 +298,7 @@ void tmp_flush(void) { lp_flush(tmp_linpool); - rfree(tmp_res.pool); + rp_free(tmp_res.pool); tmp_res.pool = rp_new(tmp_res.parent, "TMP"); } @@ -449,7 +449,7 @@ mb_free(void *m) return; struct mblock *b = SKIP_BACK(struct mblock, data, m); - rfree(b); + rfree(&b->r); } diff --git a/lib/resource.h b/lib/resource.h index 911b990d..64803778 100644 --- a/lib/resource.h +++ b/lib/resource.h @@ -58,6 +58,12 @@ void rmove(void *, pool *); /* Move to a different pool */ void *ralloc(pool *, struct resclass *); +pool *rp_new(pool *, const char *); /* Create a new pool */ +pool *rp_newf(pool *, const char *, ...); /* Create a new pool with a formatted string as its name */ +void rp_init(pool *, const char *); /* Init a new pool */ +void rp_initf(pool *, const char *, ...); /* Init a new pool with a formatted string as its name */ +static inline void rp_free(pool *p) { rfree(&p->r); } /* Free the whole pool */ + extern pool root_pool; /* Normal memory blocks */ @@ -111,6 +117,7 @@ slab *sl_new(pool *, unsigned size); void *sl_alloc(slab *); void *sl_allocz(slab *); void sl_free(void *); +void sl_delete(slab *); /* * Low-level memory allocation functions, please don't use diff --git a/nest/cli.c b/nest/cli.c index 39a3eef7..29591d26 100644 --- a/nest/cli.c +++ b/nest/cli.c @@ -421,7 +421,7 @@ cli_free(cli *c) c->sock = NULL; } else - rfree(c->pool); + rp_free(c->pool); } /** diff --git a/nest/proto.c b/nest/proto.c index 280585dd..1b25dfe9 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -1116,7 +1116,7 @@ proto_cleanup(struct proto *p) { CALL(p->proto->cleanup, p); - rfree(p->pool); + rp_free(p->pool); p->pool = NULL; p->active = 0; diff --git a/nest/rt-show.c b/nest/rt-show.c index a5c7dc8f..eacd4e31 100644 --- a/nest/rt-show.c +++ b/nest/rt-show.c @@ -227,7 +227,7 @@ rt_show_export_stopped_cleanup(struct rt_export_request *req) req->hook = NULL; /* And free the CLI (deferred) */ - rfree(d->cli->pool); + rp_free(d->cli->pool); } static int diff --git a/nest/rt-table.c b/nest/rt-table.c index b18727b1..cec13318 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -2027,7 +2027,7 @@ rt_export_stopped(struct rt_export_hook *hook) rem_node(&hook->n); /* Free the hook itself together with its pool */ - rfree(hook->pool); + rp_free(hook->pool); } static inline void diff --git a/proto/babel/babel.c b/proto/babel/babel.c index d398da8e..e95a0ead 100644 --- a/proto/babel/babel.c +++ b/proto/babel/babel.c @@ -1881,7 +1881,7 @@ babel_remove_iface(struct babel_proto *p, struct babel_iface *ifa) rem_node(NODE ifa); - rfree(ifa->pool); /* contains ifa itself, locks, socket, etc */ + rp_free(ifa->pool); /* contains ifa itself, locks, socket, etc */ } static int diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index 8bff4c78..4e6524f4 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -1867,7 +1867,7 @@ bgp_free_pending_tx(struct bgp_channel *c) ASSERT_DIE(c->ptx); ASSERT_DIE(c->ptx->pool); - rfree(c->ptx->pool); + rp_free(c->ptx->pool); c->ptx = NULL; } diff --git a/proto/mrt/mrt.c b/proto/mrt/mrt.c index 82fd426a..92c19b63 100644 --- a/proto/mrt/mrt.c +++ b/proto/mrt/mrt.c @@ -590,7 +590,7 @@ mrt_table_dump_free(struct mrt_table_dump_state *s) config_del_obstacle(s->config); - rfree(s->pool); + rp_free(s->pool); } diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index 37f642d1..0eecb432 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -311,7 +311,7 @@ ospf_iface_remove(struct ospf_iface *ifa) ospf_iface_sm(ifa, ISM_DOWN); rem_node(NODE ifa); - rfree(ifa->pool); + rp_free(ifa->pool); } void diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c index b0fdc42f..2c73d251 100644 --- a/proto/ospf/neighbor.c +++ b/proto/ospf/neighbor.c @@ -120,7 +120,7 @@ ospf_neigh_down(struct ospf_neighbor *n) s_get(&(n->dbsi)); release_lsrtl(p, n); rem_node(NODE n); - rfree(n->pool); + rp_free(n->pool); OSPF_TRACE(D_EVENTS, "Neighbor %R on %s removed", rid, ifa->ifname); } diff --git a/proto/radv/radv.c b/proto/radv/radv.c index 434155dc..eb15f9cb 100644 --- a/proto/radv/radv.c +++ b/proto/radv/radv.c @@ -323,7 +323,7 @@ radv_iface_remove(struct radv_iface *ifa) rem_node(NODE ifa); - rfree(ifa->pool); + rp_free(ifa->pool); } static void diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c index efb408e0..8481bb6e 100644 --- a/sysdep/unix/io-loop.c +++ b/sysdep/unix/io-loop.c @@ -746,7 +746,7 @@ bird_thread_cleanup(void *_thr) pthread_attr_destroy(&thr->thread_attr); /* Free all remaining memory */ - rfree(thr->pool); + rp_free(thr->pool); } static struct bird_thread * @@ -839,7 +839,7 @@ bird_thread_shutdown(void * _ UNUSED) /* Stop the meta loop */ birdloop_leave(thr->meta); domain_free(thr->meta->time.domain); - rfree(thr->meta->pool); + rp_free(thr->meta->pool); /* Local pages not needed anymore */ flush_local_pages(); @@ -990,7 +990,7 @@ bird_thread_show(void *data) cli_write_trigger(tsd->cli); DOMAIN_FREE(control, tsd->lock); - rfree(tsd->pool); + rp_free(tsd->pool); the_bird_unlock(); } @@ -1258,7 +1258,7 @@ birdloop_free(struct birdloop *loop) ASSERT_DIE(loop->thread == NULL); domain_free(loop->time.domain); - rfree(loop->pool); + rp_free(loop->pool); } static void -- cgit v1.2.3