Merge pull request #13386 from nikitamikhaylov/text-log-fix-2

Deadlock in textlog
This commit is contained in:
Nikita Mikhaylov 2020-08-06 12:23:14 +04:00 committed by GitHub
commit f6fe0b9a19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,10 +91,13 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg)
elem.source_file = msg.getSourceFile(); elem.source_file = msg.getSourceFile();
elem.source_line = msg.getSourceLine(); elem.source_line = msg.getSourceLine();
std::shared_ptr<TextLog> text_log_locked{};
{
std::lock_guard<std::mutex> lock(text_log_mutex); std::lock_guard<std::mutex> lock(text_log_mutex);
if (auto log = text_log.lock()) text_log_locked = text_log.lock();
log->add(elem); }
if (text_log_locked)
text_log_locked->add(elem);
} }
} }