mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-16 18:46:15 +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
|
||||
|
|
|
@ -128,6 +128,7 @@ int main(int argc, char* argv[])
|
|||
do
|
||||
{
|
||||
int count = read(fd, chunk->payload + len, toRead - len);
|
||||
//continue;
|
||||
if (count == 0)
|
||||
throw ServerException("count = 0");
|
||||
else if (count == -1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue