X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter%2Fcodec%2FMessage.cpp;h=28a1d4587d27f6618c5170be15fe1bd390ec0fc0;hb=a59cea2b1fd2a149c4c8ad161a449bf75a36ac77;hp=049e85a2bc20b22d6aa07df9c00f4382e5fe5116;hpb=6a05cda7553cf39d5b14539f9f4b9cf829c156a6;p=anna.git diff --git a/source/diameter/codec/Message.cpp b/source/diameter/codec/Message.cpp index 049e85a..28a1d45 100644 --- a/source/diameter/codec/Message.cpp +++ b/source/diameter/codec/Message.cpp @@ -84,7 +84,12 @@ Message::~Message() { //------------------------------------------------------------------------------ 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; } @@ -124,7 +129,7 @@ void Message::initialize() throw() { //------------------------------------------------------------------------------ //------------------------------------------------------------- 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(); @@ -133,6 +138,7 @@ void Message::clear() throw(anna::RuntimeException) { a_finds.clear(); // Initialize: initialize(); + if (resetEngine) a_engine = NULL; } @@ -227,6 +233,7 @@ void Message::setApplicationId(U32 aid) throw(anna::RuntimeException) { // 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; } @@ -303,7 +310,7 @@ void Message::decode(const anna::DataBlock &db, Message *ptrAnswer) throw(anna:: trace += db.asString(); anna::Logger::debug(trace, ANNA_FILE_LOCATION); ); - clear(); + clear(false /* respect engine */); // EXCEPTION MANAGEMENT IN THIS METHOD // =================================== // DECODE PHASE @@ -773,7 +780,7 @@ void Message::fromXML(const anna::xml::Node* messageNode) throw(anna::RuntimeExc unsigned int u_aux; // Clear the message - clear(); + clear(false /* respect engine */); if(version) { i_aux = version->getIntegerValue();