- thread safe localtime and hopefully back to good performance

This commit is contained in:
SoftCoder
2015-11-21 11:30:23 -08:00
parent 9e0d227172
commit 49ae35e7cf
8 changed files with 77 additions and 37 deletions

View File

@@ -35,10 +35,11 @@ void AllocRegistry::dump(const char *path) {
int leakCount=0;
size_t leakBytes=0;
time_t debugTime = time(NULL);
struct tm *loctime = localtime (&debugTime);
//time_t debugTime = time(NULL);
//struct tm *loctime = localtime (&debugTime);
struct tm loctime = threadsafe_localtime(systemtime_now());
char szBuf2[100]="";
strftime(szBuf2,100,"%Y-%m-%d %H:%M:%S",loctime);
strftime(szBuf2,100,"%Y-%m-%d %H:%M:%S",&loctime);
#ifdef WIN32
FILE* f= _wfopen(utf8_decode(path).c_str(), L"wt");

View File

@@ -454,8 +454,9 @@ void SystemFlags::logDebugEntry(DebugType type, string debugEntry, time_t debugT
// Get the current time.
// time_t curtime = time (NULL);
// Convert it to local time representation.
struct tm *loctime = localtime (&debugTime);
strftime(szBuf2,100,"%Y-%m-%d %H:%M:%S",loctime);
//struct tm *loctime = localtime (&debugTime);
std::tm loctime = threadsafe_localtime(debugTime);
strftime(szBuf2,100,"%Y-%m-%d %H:%M:%S",&loctime);
}
/*
va_list argList;