//------------------------------------------------------------------------------
void Message::setEngine(Engine *engine) throw() {
- if (a_engine && engine != a_engine) {
+ if (!engine) {
+ LOGWARNING(anna::Logger::warning("Ignored: you must assign a valid codec engine. If you want to set NULL engine, clear the message", ANNA_FILE_LOCATION));
+ return;
+ }
+
+ if (a_engine && (engine != a_engine)) {
LOGWARNING(anna::Logger::warning("Ignored: it is not a good practice to change the codec engine once assigned. Clear the message first to set the engine again.", ANNA_FILE_LOCATION));
return;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------- Message::clear()
//------------------------------------------------------------------------------
-void Message::clear() throw(anna::RuntimeException) {
+void Message::clear(bool resetEngine) throw(anna::RuntimeException) {
for(avp_iterator it = avp_begin(); it != avp_end(); it++) { /*avp(it)->clear(); */getEngine()->releaseAvp(Avp::avp(it)); }
a_avps.clear();
a_finds.clear();
// Initialize:
initialize();
+ if (resetEngine) a_engine = NULL;
}
// Codec engine manager (a multithreaded application, normally does not achieve this point, because
// messages are prepared for each interface with the corresponding codec engine)
anna::diameter::codec::EngineManager &em = anna::diameter::codec::EngineManager::instantiate();
+ if (em.size() == 0) return;
if (em.selectFromApplicationId()) {
Engine *monostackEngine = em.getMonoStackCodecEngine();
if (monostackEngine) { a_engine = monostackEngine; return; }
trace += db.asString();
anna::Logger::debug(trace, ANNA_FILE_LOCATION);
);
- clear();
+ clear(false /* respect engine */);
// EXCEPTION MANAGEMENT IN THIS METHOD
// ===================================
// DECODE PHASE
unsigned int u_aux;
// Clear the message
- clear();
+ clear(false /* respect engine */);
if(version) {
i_aux = version->getIntegerValue();