diff --git a/src/flb_config_map.c b/src/flb_config_map.c index 8f0eaebf7d2..b5ca9347d6f 100644 --- a/src/flb_config_map.c +++ b/src/flb_config_map.c @@ -681,7 +681,7 @@ int flb_config_map_set(struct mk_list *properties, struct mk_list *map, void *co /* Populate value */ if (m->type == FLB_CONFIG_MAP_STR) { - entry->val.str = kv->val; + entry->val.str = flb_sds_create(kv->val); } else if (m->type == FLB_CONFIG_MAP_INT) { entry->val.i_num = atoi(kv->val); diff --git a/src/flb_input_chunk.c b/src/flb_input_chunk.c index 58ada38b756..ac0285c96af 100644 --- a/src/flb_input_chunk.c +++ b/src/flb_input_chunk.c @@ -308,6 +308,7 @@ struct flb_input_chunk *flb_input_chunk_map(struct flb_input_instance *in, void *chunk) { uint64_t chunk_routes_mask; + ssize_t bytes; #ifdef FLB_HAVE_METRICS int ret; @@ -351,6 +352,9 @@ struct flb_input_chunk *flb_input_chunk_map(struct flb_input_instance *in, } ic->routes_mask = chunk_routes_mask; + bytes = flb_input_chunk_get_size(ic); + flb_input_chunk_update_output_instances(ic, bytes); + return ic; } diff --git a/src/flb_parser.c b/src/flb_parser.c index cd1a87039b0..d43dbef40ef 100644 --- a/src/flb_parser.c +++ b/src/flb_parser.c @@ -105,6 +105,38 @@ int flb_parser_logfmt_do(struct flb_parser *parser, void **out_buf, size_t *out_size, struct flb_time *out_time); +/* + * This function is used to free all aspects of a parser + * which is provided by the caller of flb_create_parser. + * Specifically, this function frees all but parser.types and + * parser.decoders from a parser. + * + * This function is only to be used in parser creation routines. + */ +static void flb_interim_parser_destroy(struct flb_parser *parser) +{ + int i = 0; + if (parser->type == FLB_PARSER_REGEX) { + flb_regex_destroy(parser->regex); + flb_free(parser->p_regex); + } + + flb_free(parser->name); + if (parser->time_fmt) { + flb_free(parser->time_fmt); + flb_free(parser->time_fmt_full); + } + if (parser->time_fmt_year) { + flb_free(parser->time_fmt_year); + } + if (parser->time_key) { + flb_free(parser->time_key); + } + + mk_list_del(&parser->_head); + flb_free(parser); +} + struct flb_parser *flb_parser_create(const char *name, const char *format, const char *p_regex, const char *time_fmt, const char *time_key, @@ -201,7 +233,7 @@ struct flb_parser *flb_parser_create(const char *name, const char *format, p->time_fmt_year = flb_malloc(size + 4); if (!p->time_fmt_year) { flb_errno(); - flb_parser_destroy(p); + flb_interim_parser_destroy(p); return NULL; } @@ -224,7 +256,7 @@ struct flb_parser *flb_parser_create(const char *name, const char *format, #else flb_error("[parser] timezone offset not supported"); flb_error("[parser] you cannot use %%z/%%Z on this platform"); - flb_parser_destroy(p); + flb_interim_parser_destroy(p); return NULL; #endif } @@ -261,7 +293,7 @@ struct flb_parser *flb_parser_create(const char *name, const char *format, len = strlen(time_offset); ret = flb_parser_tzone_offset(time_offset, len, &diff); if (ret == -1) { - flb_parser_destroy(p); + flb_interim_parser_destroy(p); return NULL; } p->time_offset = diff;