Commit ca4f9f82 authored by Samuel Debionne's avatar Samuel Debionne Committed by Samuel Debionne
Browse files

Fix data race in non-thread-safe gmtime (Linux), use gmtime_r instead

parent a7101e12
......@@ -362,13 +362,13 @@ void* SaveContainerHdf5::_open(const std::string &filename, std::ios_base::openm
time_t now;
time(&now);
char buf[sizeof("2011-10-08T07:07:09Z")];
#ifdef WIN32
struct tm gmtime_now;
#ifdef WIN32
gmtime_s(&gmtime_now, &now);
strftime(buf, sizeof(buf), "%FT%TZ", &gmtime_now);
#else
strftime(buf, sizeof(buf), "%FT%TZ", gmtime(&now));
gmtime_r(&now, &gmtime_now);
#endif
strftime(buf, sizeof(buf), "%FT%TZ", &gmtime_now);
string stime = string(buf);
write_h5_attribute(file->m_file,"file_time",stime);
......@@ -527,13 +527,13 @@ void SaveContainerHdf5::_close(void* f) {
time_t now;
time(&now);
char buf[sizeof("2011-10-08T07:07:09Z")];
#ifdef WIN32
struct tm gmtime_now;
#ifdef WIN32
gmtime_s(&gmtime_now, &now);
strftime(buf, sizeof(buf), "%FT%TZ", &gmtime_now);
#else
strftime(buf, sizeof(buf), "%FT%TZ", gmtime(&now));
gmtime_r(&now, &gmtime_now);
#endif
strftime(buf, sizeof(buf), "%FT%TZ", &gmtime_now);
string etime = string(buf);
write_h5_dataset(file->m_entry,"end_time",etime);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment