fix server crash on control client disconnect (quit, exit, bye)

This commit is contained in:
Johannes Pohl 2017-06-06 22:45:28 +02:00
parent fa9715684b
commit b56d656c32
3 changed files with 12 additions and 13 deletions

View file

@ -83,7 +83,10 @@ void ControlServer::onMessageReceived(ControlSession* connection, const std::str
{
if (it->get() == connection)
{
sessions_.erase(it);
/// delete in a thread to avoid deadlock
auto func = [&](std::shared_ptr<ControlSession> s)->void{sessions_.erase(s);};
std::thread t(func, *it);
t.detach();
break;
}
}