mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Make fStartedNewLine an std::atomic_bool
While this doesnt really fix the race of adding timestamps mid-logical-line, it avoids the undefined behavior of using a bool in multiple threads.
This commit is contained in:
parent
507145d785
commit
8b22efb6f7
1 changed files with 2 additions and 2 deletions
|
@ -259,7 +259,7 @@ bool LogAcceptCategory(const char* category)
|
|||
* suppress printing of the timestamp when multiple calls are made that don't
|
||||
* end in a newline. Initialize it to true, and hold it, in the calling context.
|
||||
*/
|
||||
static std::string LogTimestampStr(const std::string &str, bool *fStartedNewLine)
|
||||
static std::string LogTimestampStr(const std::string &str, std::atomic_bool *fStartedNewLine)
|
||||
{
|
||||
string strStamped;
|
||||
|
||||
|
@ -286,7 +286,7 @@ static std::string LogTimestampStr(const std::string &str, bool *fStartedNewLine
|
|||
int LogPrintStr(const std::string &str)
|
||||
{
|
||||
int ret = 0; // Returns total number of characters written
|
||||
static bool fStartedNewLine = true;
|
||||
static std::atomic_bool fStartedNewLine(true);
|
||||
|
||||
string strTimestamped = LogTimestampStr(str, &fStartedNewLine);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue