aboutsummaryrefslogtreecommitdiff
path: root/src/timedata.cpp
diff options
context:
space:
mode:
authorMartin Zumsande <mzumsande@gmail.com>2021-09-21 22:33:05 +0200
committerMartin Zumsande <mzumsande@gmail.com>2021-09-22 22:44:42 +0200
commit64e1ddd255771e57a88a20f07dbde04a83bf0c75 (patch)
treedd962e49d1cc295a41c6b25f0dd48cd1e27b287b /src/timedata.cpp
parenta8a272ac329da679bd489e272ed1773147f59eb9 (diff)
downloadbitcoin-64e1ddd255771e57a88a20f07dbde04a83bf0c75.tar.xz
log: call LogPrint only once with time data samples
This prevents malformed log entries caused by other threads logging concurrently.
Diffstat (limited to 'src/timedata.cpp')
-rw-r--r--src/timedata.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/timedata.cpp b/src/timedata.cpp
index 354092752d..f53fbe231b 100644
--- a/src/timedata.cpp
+++ b/src/timedata.cpp
@@ -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);
}
}
}