mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-11 16:16:42 +02:00
remove session in thread
git-svn-id: svn://elaine/murooma/trunk@332 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
7a5483a101
commit
b26952f5d1
2 changed files with 5 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue