From 97d4558a6b28a7d835f03e4d3cce7b3138467acb Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 17 Jan 2018 19:46:55 +0100 Subject: [PATCH] Fixed thread unsafe handlers.erase --- src/source_language_protocol.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/source_language_protocol.cc b/src/source_language_protocol.cc index 73c99a0..23b4257 100644 --- a/src/source_language_protocol.cc +++ b/src/source_language_protocol.cc @@ -154,10 +154,10 @@ void LanguageProtocol::Client::parse_server_message() { auto id_it=handlers.find(message_id); if(id_it!=handlers.end()) { auto function=std::move(id_it->second); + handlers.erase(id_it->first); lock.unlock(); function(result_it->second, false); lock.lock(); - handlers.erase(id_it->first); } } } @@ -168,10 +168,10 @@ void LanguageProtocol::Client::parse_server_message() { auto id_it=handlers.find(message_id); if(id_it!=handlers.end()) { auto function=std::move(id_it->second); + handlers.erase(id_it->first); lock.unlock(); function(result_it->second, true); lock.lock(); - handlers.erase(id_it->first); } } } @@ -221,10 +221,10 @@ void LanguageProtocol::Client::write_request(const std::string &method, const st auto id_it=handlers.find(message_id); if(id_it!=handlers.end()) { auto function=std::move(id_it->second); + handlers.erase(id_it->first); lock.unlock(); function(boost::property_tree::ptree(), false); lock.lock(); - handlers.erase(id_it->first); } }); } @@ -236,10 +236,10 @@ void LanguageProtocol::Client::write_request(const std::string &method, const st auto id_it=handlers.find(message_id); if(id_it!=handlers.end()) { auto function=std::move(id_it->second); + handlers.erase(id_it->first); lock.unlock(); function(boost::property_tree::ptree(), false); lock.lock(); - handlers.erase(id_it->first); } } }