Skip to content

Commit faffaa8

Browse files
author
MarcoFalke
committed
log: Avoid broken SELECTCOINS log
Before this patch, the log might be corrupted by other threads logging at the same time. For example, another RPC thread: [httpworker.1] [default wallet] keypool reserve 1296 [httpworker.1] SelectCoins() best subset: Received a POST request for / from 127.0.0.1:53732 [httpworker.3] ThreadRPCServer method=getnetworkinfo user=__cookie__ [httpworker.1] 0.78125 0.1953125 0.02441406 0.00610351 0.00305175 0.00152587 total 1.01025417
1 parent 632be55 commit faffaa8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/wallet/coinselection.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector<OutputGroup>& group
279279
}
280280

281281
if (LogAcceptCategory(BCLog::SELECTCOINS)) {
282-
LogPrint(BCLog::SELECTCOINS, "SelectCoins() best subset: "); /* Continued */
282+
std::string log_message{"SelectCoins() best subset: "};
283283
for (unsigned int i = 0; i < applicable_groups.size(); i++) {
284284
if (vfBest[i]) {
285-
LogPrint(BCLog::SELECTCOINS, "%s ", FormatMoney(applicable_groups[i].m_value)); /* Continued */
285+
log_message += strprintf("%s ", FormatMoney(applicable_groups[i].m_value));
286286
}
287287
}
288-
LogPrint(BCLog::SELECTCOINS, "total %s\n", FormatMoney(nBest));
288+
LogPrint(BCLog::SELECTCOINS, "%stotal %s\n", log_message, FormatMoney(nBest));
289289
}
290290
}
291291

0 commit comments

Comments
 (0)