@@ -94,34 +94,36 @@ LockData& GetLockData() {
94
94
95
95
static void potential_deadlock_detected (const LockPair& mismatch, const LockStack& s1, const LockStack& s2)
96
96
{
97
- std::string strOutput = " " ;
98
- strOutput += " POTENTIAL DEADLOCK DETECTED\n " ;
99
- strOutput += " Previous lock order was:\n " ;
97
+ std::string log_message{} ;
98
+ log_message += " POTENTIAL DEADLOCK DETECTED\n " ;
99
+ log_message += " Previous lock order was:\n " ;
100
100
for (const LockStackItem& i : s1) {
101
+ std::string prefix{};
101
102
if (i.first == mismatch.first ) {
102
- strOutput + = " (1)" ;
103
+ prefix = " (1)" ;
103
104
}
104
105
if (i.first == mismatch.second ) {
105
- strOutput + = " (2)" ;
106
+ prefix = " (2)" ;
106
107
}
107
- strOutput += strprintf (" %s\n " , i.second .ToString ());
108
+ log_message += strprintf (" %s %s\n " , prefix , i.second .ToString ());
108
109
}
109
110
110
111
std::string mutex_a, mutex_b;
111
- strOutput += " Current lock order is:\n " ;
112
+ log_message += " Current lock order is:\n " ;
112
113
for (const LockStackItem& i : s2) {
114
+ std::string prefix{};
113
115
if (i.first == mismatch.first ) {
114
- strOutput + = " (1)" ;
116
+ prefix = " (1)" ;
115
117
mutex_a = i.second .Name ();
116
118
}
117
119
if (i.first == mismatch.second ) {
118
- strOutput + = " (2)" ;
120
+ prefix = " (2)" ;
119
121
mutex_b = i.second .Name ();
120
122
}
121
- strOutput += strprintf (" %s\n " , i.second .ToString ());
123
+ log_message += strprintf (" %s %s\n " , prefix , i.second .ToString ());
122
124
}
123
125
124
- LogPrintf (" %s\n " , strOutput );
126
+ LogPrintf (" %s\n " , log_message );
125
127
126
128
if (g_debug_lockorder_abort) {
127
129
tfm::format (std::cerr, " Assertion failed: detected inconsistent lock order for %s, details in debug log.\n " , s2.back ().second .ToString ());
0 commit comments