Skip to content

Commit 7ff7601

Browse files
authored
theading: Fix segfault in onCleanup (#30)
1 parent e9ffe6a commit 7ff7601

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/threading.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ void Threading::doCleanup() {
210210
logMessageWithTime("Threading::doCleanup");
211211
__itt_task_begin(domain, __itt_null, __itt_null, threading_doCleanup);
212212

213+
std::vector<mariadb::account_ref> empty_accounts;
214+
213215
//Will only be called from mainthread so noone can insert stuff now.
214216
for (auto& [acc,workerlist] : workers) {
215217

@@ -242,7 +244,10 @@ void Threading::doCleanup() {
242244
}
243245
}
244246
if (workerlist.empty())
245-
workers.erase(acc);
247+
empty_accounts.push_back(acc);
248+
}
249+
for (mariadb::account_ref& acc : empty_accounts) {
250+
workers.erase(acc);
246251
}
247252
lastCleanup = std::chrono::system_clock::now();
248253
__itt_task_end(domain);

0 commit comments

Comments
 (0)