Use threadsafe time functions.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 8ec51fce57
commit 2dd28ea7fd

@ -59,7 +59,8 @@ typedef struct AlertDebugLogThread_ {
static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm *t = gmtime(&time);
struct tm local_tm;
struct tm *t = gmtime_r(&time, &local_tm);
uint32_t sec = ts->tv_sec % 86400;
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",

@ -88,7 +88,8 @@ typedef struct AlertFastLogThread_ {
static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm *t = gmtime(&time);
struct tm local_tm;
struct tm *t = gmtime_r(&time, &local_tm);
uint32_t sec = ts->tv_sec % 86400;
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",

@ -697,7 +697,8 @@ static int SCPerfOutputCounterFileIface()
memset(&tval, 0, sizeof(struct timeval));
gettimeofday(&tval, NULL);
tms = (struct tm *)localtime(&tval.tv_sec);
struct tm local_tm;
tms = (struct tm *)localtime_r(&tval.tv_sec, &local_tm);
fprintf(sc_perf_op_ctx->fp, "----------------------------------------------"
"---------------------\n");

@ -76,7 +76,8 @@ typedef struct LogHttpLogThread_ {
static void CreateTimeString (const struct timeval *ts, char *str, size_t size) {
time_t time = ts->tv_sec;
struct tm *t = gmtime(&time);
struct tm local_tm;
struct tm *t = gmtime_r(&time, &local_tm);
uint32_t sec = ts->tv_sec % 86400;
snprintf(str, size, "%02d/%02d/%02d-%02d:%02d:%02d.%06u",

@ -311,7 +311,8 @@ SCError SCLogMessage(SCLogLevel log_level, char **msg, const char *file,
temp_fmt[0] = '\0';
gettimeofday(&tval, NULL);
tms = localtime(&tval.tv_sec);
struct tm local_tm;
tms = localtime_r(&tval.tv_sec, &local_tm);
cw = snprintf(temp, SC_LOG_MAX_LOG_MSG_LEN - (temp - *msg),
"%s%d/%d/%04d -- %02d:%02d:%02d",

Loading…
Cancel
Save