Replaced all instances of localtime with localtime_r

This commit is contained in:
Thulinma 2018-05-21 09:52:47 +02:00
parent 3ce86d0e4c
commit 2d9e9f3c8b
4 changed files with 8 additions and 4 deletions

View file

@ -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)){

View file

@ -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

View file

@ -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());

View file

@ -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();}