mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Switching all use of gmtime and localtime to use reentrant variants.
This was causing occasional problems with the time on processes running lots of threads. The use of gmtime in the json formatter is the likely culprit due to the fact that the json formatter runs in threads. More evidence for this is that the problem only appears to exhibit when logs are being written as JSON.
This commit is contained in:
parent
209c8936d1
commit
40e9724de7
3 changed files with 35 additions and 13 deletions
|
@ -571,7 +571,14 @@ const char* fmt_access_time(double t)
|
|||
{
|
||||
static char buf[256];
|
||||
time_t time = (time_t) t;
|
||||
strftime(buf, sizeof(buf), "%d/%m-%H:%M", localtime(&time));
|
||||
struct tm ts;
|
||||
|
||||
if ( ! localtime_r(&time, &ts) )
|
||||
{
|
||||
reporter->InternalError("unable to get time");
|
||||
}
|
||||
|
||||
strftime(buf, sizeof(buf), "%d/%m-%H:%M", &ts);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue