update transportRegistry
avoid leaks of SOCKET and leaving mutex locked when exceptions are thrown.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user