diff options
| author | Donald Sharp <sharpd@nvidia.com> | 2021-10-12 13:23:40 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@nvidia.com> | 2021-10-20 08:28:52 -0400 |
| commit | e13f12a7d147a993a0aefd0b2b0ba947746071b4 (patch) | |
| tree | c12baf53cbe5334921ed8642f06cb1ce8a264bb9 /zebra/zebra_rib.c | |
| parent | a505383d6a42259b96f5882b493f328bc1dd9301 (diff) | |
zebra: modify rib_update to be a bit smarter about malloc
rib_update() was mallocing memory then attempting to schedule
and if the schedule failed( it was already going to be run )
FRR would then free the memory. Fix this memory usage pattern
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'zebra/zebra_rib.c')
| -rw-r--r-- | zebra/zebra_rib.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 12e82dde94..fcac3328c9 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -3890,14 +3890,16 @@ void rib_update(enum rib_update_event event) { struct rib_update_ctx *ctx; - ctx = rib_update_ctx_init(0, event); + if (thread_is_scheduled(t_rib_update_threads[event])) + return; + ctx = rib_update_ctx_init(0, event); ctx->vrf_all = true; - if (!thread_add_event(zrouter.master, rib_update_handler, ctx, 0, - &t_rib_update_threads[event])) - rib_update_ctx_fini(&ctx); /* Already scheduled */ - else if (IS_ZEBRA_DEBUG_EVENT) + thread_add_event(zrouter.master, rib_update_handler, ctx, 0, + &t_rib_update_threads[event]); + + if (IS_ZEBRA_DEBUG_EVENT) zlog_debug("%s: Scheduled VRF (ALL), event %s", __func__, rib_update_event2str(event)); } |
