diff --git a/lib/util.cpp b/lib/util.cpp index 4176459c..5141dda4 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -310,9 +310,10 @@ namespace Util{ } time_t rawtime; struct tm *timeinfo; + struct tm timetmp; char buffer[100]; time(&rawtime); - timeinfo = localtime(&rawtime); + timeinfo = localtime_r(&rawtime, &timetmp); strftime(buffer, 100, "%F %H:%M:%S", timeinfo); dprintf(out, "%s[%s] ", color_time, buffer); if (progname && progpid && strlen(progname) && strlen(progpid)){ diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index fcf4c51b..295c8a77 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -223,9 +223,10 @@ int main_loop(int argc, char **argv){ dup2(output, STDERR_FILENO); time_t rawtime; struct tm *timeinfo; + struct tm tmptime; char buffer[25]; time(&rawtime); - timeinfo = localtime(&rawtime); + timeinfo = localtime_r(&rawtime, &tmptime); strftime(buffer, 25, "%c", timeinfo); std::cerr << std::endl << std::endl diff --git a/src/controller/controller_api.cpp b/src/controller/controller_api.cpp index 44ffe8c1..fed43598 100644 --- a/src/controller/controller_api.cpp +++ b/src/controller/controller_api.cpp @@ -23,7 +23,8 @@ /// Returns the challenge string for authentication, given the socket connection. std::string getChallenge(Socket::Connection & conn){ time_t Time = time(0); - tm * TimeInfo = localtime( &Time); + tm tmptime; + tm * TimeInfo = localtime_r( &Time, &tmptime); std::stringstream Date; Date << TimeInfo->tm_mday << "-" << TimeInfo->tm_mon << "-" << TimeInfo->tm_year + 1900; return Secure::md5(Date.str().c_str() + conn.getHost()); diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index 30d60ebe..a24de771 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -712,9 +712,10 @@ void Controller::statSession::ping(const Controller::sessIndex & index, unsigned if (accLogFile.good()){ time_t rawtime; struct tm *timeinfo; + struct tm tmptime; char buffer[100]; time(&rawtime); - timeinfo = localtime(&rawtime); + timeinfo = localtime_r(&rawtime, &tmptime); strftime(buffer, 100, "%F %H:%M:%S", timeinfo); accLogFile << buffer << ", " << index.ID << ", " << index.streamName << ", " << index.connector << ", " << index.host << ", " << duration << ", " << getUp()/duration/1024 << ", " << getDown()/duration/1024 << ", "; if (tags.size()){accLogFile << tagStream.str();}