]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Resource pool closing has its dedicated function
authorMaria Matejka <mq@ucw.cz>
Thu, 20 Apr 2023 19:08:38 +0000 (21:08 +0200)
committerMaria Matejka <mq@ucw.cz>
Sat, 22 Apr 2023 18:49:58 +0000 (20:49 +0200)
14 files changed:
conf/conf.c
lib/resource.c
lib/resource.h
nest/cli.c
nest/proto.c
nest/rt-show.c
nest/rt-table.c
proto/babel/babel.c
proto/bgp/attrs.c
proto/mrt/mrt.c
proto/ospf/iface.c
proto/ospf/neighbor.c
proto/radv/radv.c
sysdep/unix/io-loop.c

index daac85c1405b9d09650099cb16f53b2063969d33..2cfe7b157874fbabf5e7063a77310f4f046469c8 100644 (file)
@@ -200,7 +200,7 @@ config_free(struct config *c)
 
   ASSERT(!c->obstacle_count);
 
-  rfree(c->pool);
+  rp_free(c->pool);
 }
 
 /**
index 94b8d019ecf424efe1afd91742c7fb76367d45fb..0006bc8d414756b1ec56e01b8c7686db2e308bba 100644 (file)
@@ -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);
 }
 
 
index 911b990d6215cc15bbe07a0a1327ab39e4841202..64803778f797b0d6e3fe6b6ac9d6ecfd47baf00d 100644 (file)
@@ -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
index 39a3eef757b794a2321029093bb252c8e5ccf6fb..29591d26e19016ae29278a3110ee8a6cdf7ae708 100644 (file)
@@ -421,7 +421,7 @@ cli_free(cli *c)
     c->sock = NULL;
   }
   else
-    rfree(c->pool);
+    rp_free(c->pool);
 }
 
 /**
index 280585dd59e72e674554b5db46453b753bf169f5..1b25dfe9a417dc649fac567348e243d806023cb1 100644 (file)
@@ -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;
index a5c7dc8f347dbd2cc0c83a2914778151fc841149..eacd4e31f729281f9e40e7f5bb0734534cbd5a98 100644 (file)
@@ -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
index b18727b1b8055331c92adaa77e0bdd942441d029..cec133188b2ab9d584612843a8e2968b7e74b983 100644 (file)
@@ -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
index d398da8e1b7c6523ef848bf8d04de5e7b0bce762..e95a0eadebe851bcc08c2bc780133c718691769c 100644 (file)
@@ -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
index 8bff4c78490185b32f7221f84f1f77ec87bf68e3..4e6524f48c4b2a5fe0694fc83b4db51bda6e0aa2 100644 (file)
@@ -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;
 }
 
index 82fd426ac66a2e7aa087c9ae4efb77c541afe871..92c19b635971885fd4259041c0ec1e42f3bc069b 100644 (file)
@@ -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);
 }
 
 
index 37f642d1eb798620e1ee52b76d8d7d04713e9f34..0eecb43256fc5cb12006b9d42721a88a03df2b0d 100644 (file)
@@ -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
index b0fdc42fae5e852bae5e27d9c1c1a500a03ffb01..2c73d251fb6fbfca5113ab6eb9d97ccd07b1e9de 100644 (file)
@@ -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);
 }
index 434155dc0dc01a5489e30067543d0f7198710ec7..eb15f9cb5fb14c3898187afd4d0da4e0be2281a3 100644 (file)
@@ -323,7 +323,7 @@ radv_iface_remove(struct radv_iface *ifa)
 
   rem_node(NODE ifa);
 
-  rfree(ifa->pool);
+  rp_free(ifa->pool);
 }
 
 static void
index efb408e041cc1df459f29a1811e4b7246b56215c..8481bb6e04729f7afc189adae51b904f4cdadbaa 100644 (file)
@@ -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