Skip to content

Commit

Permalink
syslog-format: don't try to turn a timestamp to unixtime if one is no…
Browse files Browse the repository at this point in the history
…t present

If the timestamp is not actually there in the message, we still tried
to call convert_and_normalize_wall_clock_time_to_unix_time_with_tz_hint(),
which in turn calls mktime(), which is a heavyweight operation.

Let's not do that.

Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
  • Loading branch information
bazsi committed May 17, 2024
1 parent c758c6e commit fa3ab9f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/syslogformat/syslog-format.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ _syslog_format_parse_timestamp(LogMessage *msg, UnixTime *stamp,
result = scan_rfc5424_timestamp(data, length, &wct);
}

if ((parse_flags & LP_NO_PARSE_DATE) == 0)
if (result && (parse_flags & LP_NO_PARSE_DATE) == 0)
{
convert_and_normalize_wall_clock_time_to_unix_time_with_tz_hint(&wct, stamp, recv_timezone_ofs);

Expand Down

0 comments on commit fa3ab9f

Please sign in to comment.