mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-20 15:10:46 +02: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 <netaddress.h>
|
||||||
#include <node/ui_interface.h>
|
#include <node/ui_interface.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
|
#include <tinyformat.h>
|
||||||
#include <util/system.h>
|
#include <util/system.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
#include <warnings.h>
|
#include <warnings.h>
|
||||||
@ -98,11 +99,12 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (LogAcceptCategory(BCLog::NET)) {
|
if (LogAcceptCategory(BCLog::NET)) {
|
||||||
|
std::string log_message{"time data samples: "};
|
||||||
for (const int64_t n : vSorted) {
|
for (const int64_t n : vSorted) {
|
||||||
LogPrint(BCLog::NET, "%+d ", n); /* Continued */
|
log_message += strprintf("%+d ", n);
|
||||||
}
|
}
|
||||||
LogPrint(BCLog::NET, "| "); /* Continued */
|
log_message += strprintf("| median offset = %+d (%+d minutes)", nTimeOffset, nTimeOffset / 60);
|
||||||
LogPrint(BCLog::NET, "nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset / 60);
|
LogPrint(BCLog::NET, "%s\n", log_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user