Skip to content

Commit

Permalink
Merge pull request #1986 from KyleFromKitware/fix-localtimedate
Browse files Browse the repository at this point in the history
Fix race condition in LocalTimeDate()
  • Loading branch information
eisenhauer authored Feb 26, 2020
2 parents e0c14ca + 16eee73 commit 9067e90
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion source/adios2/helper/adiosSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ bool IsLittleEndian() noexcept

std::string LocalTimeDate() noexcept
{
struct tm now_tm;
char buf[30];

std::time_t now =
std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());

return std::string(ctime(&now));
#ifdef _WIN32
localtime_s(&now_tm, &now);
#else
localtime_r(&now, &now_tm);
#endif
strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y\n", &now_tm);

return std::string(buf);
}

bool IsRowMajor(const std::string hostLanguage) noexcept
Expand Down

0 comments on commit 9067e90

Please sign in to comment.