Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fluent/fluent-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
edsiper committed Nov 15, 2020
2 parents 0855895 + 221140a commit 92d43a1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/flb_config_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/flb_input_chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
38 changes: 35 additions & 3 deletions src/flb_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand All @@ -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
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 92d43a1

Please sign in to comment.