fixed deadlock in server shutdown

This commit is contained in:
badaix 2016-11-09 11:45:35 +01:00
parent 341466ceb5
commit 935899b0a2
5 changed files with 35 additions and 23 deletions

View file

@ -404,16 +404,24 @@ void StreamServer::start()
void StreamServer::stop()
{
std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_);
for (auto session: sessions_)//it = sessions_.begin(); it != sessions_.end(); ++it)
if (streamManager_)
{
if (session)
{
session->stop();
session = nullptr;
}
streamManager_->stop();
streamManager_ = nullptr;
}
{
std::lock_guard<std::recursive_mutex> mlock(sessionsMutex_);
for (auto session: sessions_)//it = sessions_.begin(); it != sessions_.end(); ++it)
{
if (session)
{
session->stop();
session = nullptr;
}
}
sessions_.clear();
}
sessions_.clear();
if (controlServer_)
{
@ -426,11 +434,5 @@ void StreamServer::stop()
acceptor_->cancel();
acceptor_ = nullptr;
}
if (streamManager_)
{
streamManager_->stop();
streamManager_ = nullptr;
}
}