From: seolheui, kim Date: Fri, 4 Jan 2019 01:03:44 +0000 (+0900) Subject: Change std::localtime to localtime_r in file-sink.cpp X-Git-Tag: submit/tizen_4.0/20190104.074846~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d4d391a735ec8efda38ffce486c9e449c6e6622;p=platform%2Fcore%2Fsecurity%2Fode.git Change std::localtime to localtime_r in file-sink.cpp - To guarantee of thread-safe Change-Id: I707173361df0d5f0b2d901d30d4f588178301575 Signed-off-by: seolheui, kim --- diff --git a/server/file-sink.cpp b/server/file-sink.cpp index 50b86d1..a6d1a93 100644 --- a/server/file-sink.cpp +++ b/server/file-sink.cpp @@ -85,7 +85,21 @@ void FileLogSink::write(const std::string &message) resize(); auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - std::tm tm = *std::localtime(&now); + std::tm tm = { + .tm_sec = 0, + .tm_min = 0, + .tm_hour = 0, + .tm_mday = 1, + .tm_mon = 1, + .tm_year = 0, + .tm_wday = 0, + .tm_yday = 0, + .tm_isdst = 1, + }; + + if (::localtime_r(&now, &tm) == nullptr) + std::cerr << "Failed to get local time" << std::endl; + std::string log("[" + std::to_string(tm.tm_hour) + ":" + std::to_string(tm.tm_min)