Skip to content

Commit 0adf3e4

Browse files
committed
config: integrate router context creation and destruction
Create router in config init and destroy in config exit. Ensure router lifecycle aligns with config lifecycle. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
1 parent b361654 commit 0adf3e4

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

include/fluent-bit/flb_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
#include <monkey/mk_core.h>
3333

34+
struct flb_router;
35+
3436
#define FLB_CONFIG_FLUSH_SECS 1
3537
#define FLB_CONFIG_HTTP_LISTEN "0.0.0.0"
3638
#define FLB_CONFIG_HTTP_PORT "2020"
@@ -293,9 +295,7 @@ struct flb_config {
293295
int hot_reload_watchdog_timeout_seconds;
294296

295297
/* Routing */
296-
size_t route_mask_size;
297-
size_t route_mask_slots;
298-
uint64_t *route_empty_mask;
298+
struct flb_router *router;
299299
#ifdef FLB_SYSTEM_WINDOWS
300300
/* maxstdio (Windows) */
301301
int win_maxstdio;

src/flb_config.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,14 @@ struct flb_config *flb_config_init()
304304
}
305305

306306
/* Routing */
307-
flb_routes_mask_set_size(1, config);
307+
config->router = flb_router_create(config);
308+
if (!config->router) {
309+
flb_error("[config] could not create router");
310+
flb_cf_destroy(cf);
311+
flb_free(config);
312+
return NULL;
313+
}
314+
flb_routes_mask_set_size(1, config->router);
308315

309316
config->cio = NULL;
310317
config->storage_path = NULL;
@@ -613,7 +620,8 @@ void flb_config_exit(struct flb_config *config)
613620

614621
/* release task map */
615622
flb_config_task_map_resize(config, 0);
616-
flb_routes_empty_mask_destroy(config);
623+
624+
flb_router_destroy(config->router);
617625

618626
/* Clean up router input routes */
619627
flb_router_routes_destroy(&config->input_routes);

0 commit comments

Comments
 (0)