From dfdd76a1bb0fa5b616f116f428e1e72cb9ed1818 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 15 Oct 2019 10:32:29 -0400 Subject: [PATCH] fixed #1429. Don't use monotonic timer for Win32 --- libi2pd/RouterContext.cpp | 10 ++++++++++ libi2pd/RouterContext.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/libi2pd/RouterContext.cpp b/libi2pd/RouterContext.cpp index 5ac26f7c..3323de87 100644 --- a/libi2pd/RouterContext.cpp +++ b/libi2pd/RouterContext.cpp @@ -27,7 +27,12 @@ namespace i2p void RouterContext::Init () { srand (i2p::util::GetMillisecondsSinceEpoch () % 1000); +#ifdef WIN32 + // for compatibility with WinXP + m_StartupTime = i2p::util::GetSecondsSinceEpoch (); +#else m_StartupTime = std::chrono::steady_clock::now(); +#endif if (!Load ()) CreateNewRouter (); m_Decryptor = m_Keys.CreateDecryptor (nullptr); @@ -716,7 +721,12 @@ namespace i2p uint32_t RouterContext::GetUptime () const { +#ifdef WIN32 + // for compatibility with WinXP + return i2p::util::GetSecondsSinceEpoch () - m_StartupTime; +#else return std::chrono::duration_cast (std::chrono::steady_clock::now() - m_StartupTime).count (); +#endif } bool RouterContext::Decrypt (const uint8_t * encrypted, uint8_t * data, BN_CTX * ctx) const diff --git a/libi2pd/RouterContext.h b/libi2pd/RouterContext.h index fc4b90dc..9385e11f 100644 --- a/libi2pd/RouterContext.h +++ b/libi2pd/RouterContext.h @@ -137,7 +137,11 @@ namespace i2p std::shared_ptr m_Decryptor; uint64_t m_LastUpdateTime; // in seconds bool m_AcceptsTunnels, m_IsFloodfill; +#ifdef WIN32 + uint64_t m_StartupTime = 0; // in seconds since epoch +#else std::chrono::time_point m_StartupTime; +#endif uint64_t m_BandwidthLimit; // allowed bandwidth int m_ShareRatio; RouterStatus m_Status;