diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-11-20 22:26:50 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-11-21 00:50:53 +0000 |
commit | 96e6b439705cff5806974bb34e4b46db40dd3dbd (patch) | |
tree | 20fe64f9b065f41dfe904be19249bf5cc33a86ee /contrib/epee | |
parent | Merge pull request #4781 (diff) | |
download | monero-96e6b439705cff5806974bb34e4b46db40dd3dbd.tar.xz |
blockchain_stats: don't use gmtime_r on Windows
In some cases, it doesn't like it (I don't know the details).
Factor into a new epee function
Diffstat (limited to 'contrib/epee')
-rw-r--r-- | contrib/epee/include/misc_os_dependent.h | 9 | ||||
-rw-r--r-- | contrib/epee/src/mlog.cpp | 8 |
2 files changed, 11 insertions, 6 deletions
diff --git a/contrib/epee/include/misc_os_dependent.h b/contrib/epee/include/misc_os_dependent.h index 0d09683d6..5fffde8d5 100644 --- a/contrib/epee/include/misc_os_dependent.h +++ b/contrib/epee/include/misc_os_dependent.h @@ -124,5 +124,14 @@ namespace misc_utils return boost::lexical_cast<std::string>(pthread_self()); #endif } + + inline bool get_gmt_time(time_t t, struct tm &tm) + { +#ifdef _WIN32 + return gmtime_s(&tm, &t); +#else + return gmtime_r(&t, &tm); +#endif + } } } diff --git a/contrib/epee/src/mlog.cpp b/contrib/epee/src/mlog.cpp index 638155b6b..00d848388 100644 --- a/contrib/epee/src/mlog.cpp +++ b/contrib/epee/src/mlog.cpp @@ -40,6 +40,7 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include "string_tools.h" +#include "misc_os_dependent.h" #include "misc_log_ex.h" #undef MONERO_DEFAULT_LOG_CATEGORY @@ -58,12 +59,7 @@ static std::string generate_log_filename(const char *base) char tmp[200]; struct tm tm; time_t now = time(NULL); - if -#ifdef WIN32 - (!gmtime_s(&tm, &now)) -#else - (!gmtime_r(&now, &tm)) -#endif + if (!epee::misc_utils::get_gmt_time(now, tm)) snprintf(tmp, sizeof(tmp), "part-%u", ++fallback_counter); else strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", &tm); |