void ProgrammedAnswers::clear() throw () {
try {
anna::diameter::codec::EngineManager &em = anna::diameter::codec::EngineManager::instantiate();
+ anna::diameter::codec::Engine *engine;
+
for (reacting_answers_const_iterator it = a_deques.begin(); it != a_deques.end(); it++) {
anna::diameter::codec::Message *message = *(it->second->begin());
- em.getCodecEngine(message->getApplicationId())->releaseMessage(message);
- delete (it->second);
+ engine = em.getCodecEngine(message->getApplicationId());
+ if (engine) {
+ engine->releaseMessage(message);
+ delete (it->second);
+ }
+ else {
+ LOGWARNING(anna::Logger::warning("Cannot release a message for which i don't know the codec engine (check the registered stack id regarding the message application id) !", ANNA_FILE_LOCATION));
+ }
}
a_deques.clear();
}
}
void ProgrammedAnswers::nextMessage(int code) throw () { //pops the deque and release the message (when deque is not empty: deque::empty)
+ anna::diameter::codec::Engine *engine;
+
try {
reacting_answers_const_iterator it = a_deques.find(code);
if (it != a_deques.end()) {
if (!it->second->empty()) {
+ anna::diameter::codec::Message *message = *(it->second->begin());
if (a_rotate) {
- addMessage(code, *(it->second->begin()));
+ addMessage(code, message);
} else {
- anna::diameter::codec::EngineManager &em = anna::diameter::codec::EngineManager::instantiate();
- anna::diameter::codec::Message *message = *(it->second->begin());
- em.getCodecEngine(message->getApplicationId())->releaseMessage(message);
+ engine = anna::diameter::codec::EngineManager::instantiate().getCodecEngine(message->getApplicationId());
+ if (engine) {
+ engine->releaseMessage(message);
+ }
+ else {
+ LOGWARNING(anna::Logger::warning("Cannot release a message for which i don't know the codec engine (check the registered stack id regarding the message application id) !", ANNA_FILE_LOCATION));
+ return;
+ }
}
it->second->pop_front();
}