mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-26 15:36:19 +01:00
Merge #21043: net: Avoid UBSan warning in ProcessMessage(...)
3ddbf22ed1util: Disallow negative mocktime (MarcoFalke)f5f2f97168net: Avoid UBSan warning in ProcessMessage(...) (practicalswift) Pull request description: Avoid UBSan warning in `ProcessMessage(...)`. Context: https://github.com/bitcoin/bitcoin/pull/20380#issuecomment-770427182 (thanks Crypt-iQ!) ACKs for top commit: MarcoFalke: re-ACK3ddbf22ed1only change is adding patch written by me ajtowns: ACK3ddbf22ed1-- code review only Tree-SHA512: e8d7af0457ca86872b75a4e406c0a93aafd841c2962e244e147e748cc7ca118c56be0fdafe53765f4b291410030b2c3cc8f76f733b37a955d34fc885ab6037b9
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
|
||||
#include <util/time.h>
|
||||
|
||||
#include <util/check.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <ctime>
|
||||
@@ -18,7 +20,7 @@
|
||||
|
||||
void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread::sleep_for(n); }
|
||||
|
||||
static std::atomic<int64_t> nMockTime(0); //!< For unit testing
|
||||
static std::atomic<int64_t> nMockTime(0); //!< For testing
|
||||
|
||||
int64_t GetTime()
|
||||
{
|
||||
@@ -46,6 +48,7 @@ template std::chrono::microseconds GetTime();
|
||||
|
||||
void SetMockTime(int64_t nMockTimeIn)
|
||||
{
|
||||
Assert(nMockTimeIn >= 0);
|
||||
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user