remove session in thread

git-svn-id: svn://elaine/murooma/trunk@332 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-12-30 09:09:24 +00:00
parent 7a5483a101
commit b26952f5d1
2 changed files with 5 additions and 2 deletions

View file

@ -17,12 +17,14 @@ ControlServer::ControlServer(unsigned short port) : port_(port), headerChunk(NUL
void ControlServer::send(shared_ptr<msg::BaseMessage> message)
{
std::unique_lock<std::mutex> mlock(mutex);
for (std::set<shared_ptr<ServerSession>>::iterator it = sessions.begin(); it != sessions.end(); )
for (auto it = sessions.begin(); it != sessions.end(); )
{
if (!(*it)->active())
{
logO << "Session inactive. Removing\n";
(*it)->stop();
auto func = [](shared_ptr<ServerSession> s)->void{s->stop();};
std::thread t(func, *it);
t.detach();
sessions.erase(it++);
}
else