summaryrefslogtreecommitdiff
path: root/nest/route.h
diff options
context:
space:
mode:
authorMaria Matejka <mq@jmq.cz>2021-12-01 21:52:55 +0000
committerMaria Matejka <mq@jmq.cz>2021-12-01 21:52:55 +0000
commitb2bac7ae91253b0bd27e9b03ec5fc30ac1522928 (patch)
tree8d8d18cbeaa5516fe5dd498fa53a355b078f6b8c /nest/route.h
parent387b279f605c096c6ecb16d6608c700c533edb13 (diff)
Faster shutdown and cleanups by freeing route attributes strictly from main loop
Diffstat (limited to 'nest/route.h')
-rw-r--r--nest/route.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/nest/route.h b/nest/route.h
index afd7a783..9093108b 100644
--- a/nest/route.h
+++ b/nest/route.h
@@ -883,14 +883,22 @@ static inline rta *rta_clone(rta *r) {
return r;
}
-void rta__free(rta *r);
+#define RTA_OBSOLETE_LIMIT 512
+
+extern _Atomic u32 rta_obsolete_count;
+extern event rta_cleanup_event;
+
static inline void rta_free(rta *r) {
if (!r)
return;
u32 uc = atomic_fetch_sub_explicit(&r->uc, 1, memory_order_acq_rel);
- if (uc == 1)
- rta__free(r);
+ if (uc > 1)
+ return;
+
+ u32 obs = atomic_fetch_add_explicit(&rta_obsolete_count, 1, memory_order_acq_rel);
+ if (obs == RTA_OBSOLETE_LIMIT)
+ ev_send(&global_work_list, &rta_cleanup_event);
}
rta *rta_do_cow(rta *o, linpool *lp);