Skip to content

Commit 88c0f17

Browse files
committed
config: initialize multiline parsers
Signed-off-by: Eduardo Silva <[email protected]>
1 parent fc153b0 commit 88c0f17

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

include/fluent-bit/flb_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ struct flb_config {
9494
/* Parsers instances */
9595
struct mk_list parsers;
9696

97-
/* Multiline instances */
98-
struct mk_list multilines;
97+
/* Multiline core parser definitions */
98+
struct mk_list multiline_parsers;
9999

100100
/* Outputs instances */
101101
struct mk_list outputs; /* list of output plugins */

src/flb_config.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <fluent-bit/flb_http_server.h>
4242
#include <fluent-bit/flb_plugin.h>
4343
#include <fluent-bit/flb_utils.h>
44+
#include <fluent-bit/multiline/flb_ml.h>
4445

4546
const char *FLB_CONF_ENV_LOGLEVEL = "FLB_LOG_LEVEL";
4647

@@ -198,7 +199,6 @@ struct flb_config *flb_config_init()
198199
mk_list_init(&config->out_plugins);
199200
mk_list_init(&config->inputs);
200201
mk_list_init(&config->parsers);
201-
mk_list_init(&config->multilines);
202202
mk_list_init(&config->filters);
203203
mk_list_init(&config->outputs);
204204
mk_list_init(&config->proxies);
@@ -210,6 +210,11 @@ struct flb_config *flb_config_init()
210210
/* Environment */
211211
config->env = flb_env_create();
212212

213+
214+
/* Multiline core */
215+
mk_list_init(&config->multiline_parsers);
216+
flb_ml_init(config);
217+
213218
/* Register static plugins */
214219
ret = flb_plugins_register(config);
215220
if (ret == -1) {

src/flb_parser.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <fluent-bit/flb_env.h>
3333
#include <fluent-bit/flb_str.h>
3434
#include <fluent-bit/multiline/flb_ml.h>
35+
#include <fluent-bit/multiline/flb_ml_parser.h>
3536

3637
#include <sys/types.h>
3738
#include <sys/stat.h>
@@ -352,10 +353,14 @@ void flb_parser_exit(struct flb_config *config)
352353
struct mk_list *head;
353354
struct flb_parser *parser;
354355

356+
/* release 'parsers' */
355357
mk_list_foreach_safe(head, tmp, &config->parsers) {
356358
parser = mk_list_entry(head, struct flb_parser, _head);
357359
flb_parser_destroy(parser);
358360
}
361+
362+
/* release 'multiline parsers' */
363+
flb_ml_exit(config);
359364
}
360365

361366
static int proc_types_str(const char *types_str, struct flb_parser_types **types)
@@ -606,7 +611,7 @@ static int multiline_parser_conf_file(const char *cfg, struct mk_rconf *fconf,
606611
int flush_timeout;
607612
struct mk_list *head;
608613
struct mk_rconf_section *section;
609-
struct flb_ml *ml;
614+
struct flb_ml_parser *ml_parser;
610615

611616
/* Read all [PARSER] sections */
612617
mk_list_foreach(head, &fconf->sections) {
@@ -676,9 +681,13 @@ static int multiline_parser_conf_file(const char *cfg, struct mk_rconf *fconf,
676681
flush_timeout = atoi(tmp);
677682
}
678683

679-
ml = flb_ml_create(config, name, type, match_string, negate,
680-
flush_timeout, key_content, key_group, key_pattern,
681-
NULL, parser);
684+
ml_parser = flb_ml_parser_create(config, name, type, match_string,
685+
negate, flush_timeout, key_content,
686+
key_group, key_pattern,
687+
NULL, parser);
688+
if (!ml_parser) {
689+
goto fconf_error;
690+
}
682691

683692
flb_sds_destroy(name);
684693
flb_sds_destroy(match_string);
@@ -742,6 +751,7 @@ int flb_parser_conf_file(const char *file, struct flb_config *config)
742751
return -1;
743752
}
744753

754+
/* processs [MULTILINE_PARSER]'s sections */
745755
ret = multiline_parser_conf_file(cfg, fconf, config);
746756
if (ret == -1) {
747757
mk_rconf_free(fconf);

0 commit comments

Comments
 (0)