void ProtocolManager::onProtocolShutdownTimeout(Event *e) { HAGGLE_DBG("Checking for still registered protocols: num registered=%lu\n", protocol_registry.size()); if (!protocol_registry.empty()) { while (!protocol_registry.empty()) { Protocol *p = (*protocol_registry.begin()).second; protocol_registry.erase(p->getId()); HAGGLE_DBG("Protocol \'%s\' still registered after shutdown. Detaching it!\n", p->getName()); // We are not going to join with these threads, so we detach. if (p->isRunning()) { // In detached state, the protocol will delete itself // once it stops running. p->detach(); p->cancel(); // We have to clear the protocol's send queue as it may contain // data objects whose send verdict managersa are // waiting for. Clearing the queue will evict all data objects // from its queue with a FAILURE verdict. p->closeAndClearQueue(); } else { delete p; } } unregisterWithKernel(); } }