update transportRegistry

avoid leaks of SOCKET and leaving mutex locked
when exceptions are thrown.
This commit is contained in:
Michael Davidsaver
2018-02-01 18:54:25 -08:00
parent 5a86835a6f
commit 58f996fd98
14 changed files with 278 additions and 298 deletions

View File

@@ -369,41 +369,8 @@ void ServerContextImpl::destroyAllTransports()
if (size == 0)
return;
LOG(logLevelDebug, "Server context still has %zu transport(s) active and closing...", size);
for (size_t i = 0; i < size; i++)
{
const Transport::shared_pointer& transport = transports[i];
try
{
transport->close();
}
catch (std::exception &e)
{
// do all exception safe, log in case of an error
LOG(logLevelError, "Unhandled exception caught from client code at %s:%d: %s", __FILE__, __LINE__, e.what());
}
catch (...)
{
// do all exception safe, log in case of an error
LOG(logLevelError, "Unhandled exception caught from client code at %s:%d.", __FILE__, __LINE__);
}
}
// now clear all (release)
_transportRegistry.clear();
for (size_t i = 0; i < size; i++)
{
const Transport::shared_pointer& transport = transports[i];
transport->waitJoin();
LEAK_CHECK(transport, "tcp transport")
if(!transport.unique()) {
LOG(logLevelError, "Closed transport %s still has use_count=%u",
transport->getRemoteName().c_str(),
(unsigned)transport.use_count());
}
}
}
void ServerContext::printInfo(int lvl)