From bcbb959a3493bfcd97aafbe0b26b431280bcd842 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Mon, 24 Aug 2015 13:36:47 +0200 Subject: [PATCH] applog: remove useless mutex --- compat.h | 5 ++++- util.cpp | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compat.h b/compat.h index 7f993ab..3e9d975 100644 --- a/compat.h +++ b/compat.h @@ -4,8 +4,9 @@ #ifdef WIN32 #include +#include -extern int opt_priority; +#define localtime_r(src, dst) localtime_s(dst, src) static __inline void sleep(int secs) { @@ -16,6 +17,8 @@ enum { PRIO_PROCESS = 0, }; +extern int opt_priority; + static __inline int setpriority(int which, int who, int prio) { switch (opt_priority) { diff --git a/util.cpp b/util.cpp index 41d6fda..d0b3f1d 100644 --- a/util.cpp +++ b/util.cpp @@ -105,13 +105,10 @@ void applog(int prio, const char *fmt, ...) const char* color = ""; char *f; int len; - struct tm tm, *tm_p; + struct tm tm; time_t now = time(NULL); - pthread_mutex_lock(&applog_lock); - tm_p = localtime(&now); - memcpy(&tm, tm_p, sizeof(tm)); - pthread_mutex_unlock(&applog_lock); + localtime_r(&now, &tm); switch (prio) { case LOG_ERR: color = CL_RED; break;