mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 09:53:47 +01:00
log: call LogPrint only once with time data samples
This prevents malformed log entries caused by other threads logging concurrently.
This commit is contained in:
parent
a8a272ac32
commit
64e1ddd255
@ -11,6 +11,7 @@
|
||||
#include <netaddress.h>
|
||||
#include <node/ui_interface.h>
|
||||
#include <sync.h>
|
||||
#include <tinyformat.h>
|
||||
#include <util/system.h>
|
||||
#include <util/translation.h>
|
||||
#include <warnings.h>
|
||||
@ -98,11 +99,12 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
||||
}
|
||||
|
||||
if (LogAcceptCategory(BCLog::NET)) {
|
||||
std::string log_message{"time data samples: "};
|
||||
for (const int64_t n : vSorted) {
|
||||
LogPrint(BCLog::NET, "%+d ", n); /* Continued */
|
||||
log_message += strprintf("%+d ", n);
|
||||
}
|
||||
LogPrint(BCLog::NET, "| "); /* Continued */
|
||||
LogPrint(BCLog::NET, "nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset / 60);
|
||||
log_message += strprintf("| median offset = %+d (%+d minutes)", nTimeOffset, nTimeOffset / 60);
|
||||
LogPrint(BCLog::NET, "%s\n", log_message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user