Fix crash when unlinking dplus

master
Geoffrey Merck 4 years ago
parent 247e6ca6b9
commit e9e836ac83

@ -61,14 +61,14 @@ CDPlusProtocolHandler* CDPlusProtocolHandlerPool::getHandler(unsigned int port)
if (proto) { if (proto) {
if (proto->open()) { if (proto->open()) {
m_pool[port] = proto; m_pool[port] = proto;
CLog::logInfo("New CDPlusProtocolHandler now on UDP port %u.\n", port); CLog::logInfo("New D Plus Protocol Handler now on UDP port %u.\n", port);
} else { } else {
delete proto; delete proto;
proto = NULL; proto = NULL;
CLog::logInfo("ERROR: Can't open new DPlus UDP port %u!\n", port); CLog::logError("Can't open new DPlus UDP port %u!\n", port);
} }
} else } else
CLog::logInfo("ERROR: Can't allocate new CDPlusProtocolHandler at port %u\n", port); CLog::logError("Can't allocate new DPlus ProtocolHandler at port %u\n", port);
return proto; return proto;
} }
@ -77,15 +77,16 @@ void CDPlusProtocolHandlerPool::release(CDPlusProtocolHandler *handler)
assert(handler != NULL); assert(handler != NULL);
for (auto it=m_pool.begin(); it!=m_pool.end(); it++) { for (auto it=m_pool.begin(); it!=m_pool.end(); it++) {
if (it->second == handler) { if (it->second == handler) {
it->second->close();
delete it->second;
CLog::logInfo("Releasing CDPlusProtocolHandler on port %u.\n", it->first);
m_pool.erase(it); m_pool.erase(it);
handler->close();
delete handler;
m_index = m_pool.end(); // m_index might be ut of order so reset it
CLog::logInfo("Releasing DPlus ProtocolHandler on port %u.\n", it->first);
return; return;
} }
} }
// we should never get here! // we should never get here!
CLog::logInfo("ERROR: could not find CDPlusProtocolHander (port=%u) to release!\n", handler->getPort()); CLog::logInfo("ERROR: could not find DPlus ProtocolHander (port=%u) to release!\n", handler->getPort());
} }
DPLUS_TYPE CDPlusProtocolHandlerPool::read() DPLUS_TYPE CDPlusProtocolHandlerPool::read()

Loading…
Cancel
Save

Powered by TurnKey Linux.