X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdiameter.comm%2FSession.cpp;h=736635cae23f3f6ceb94e61d139c3d39bfce4cc6;hb=61f81319bb14f08094488e8a2478ff4e0d6d661a;hp=fada503a297e2fd61dc299fa6ffbe098d2eeba4f;hpb=93366a0bda79e6fd6e7dad6316bfcf8cc82f5731;p=anna.git diff --git a/source/diameter.comm/Session.cpp b/source/diameter.comm/Session.cpp index fada503..736635c 100644 --- a/source/diameter.comm/Session.cpp +++ b/source/diameter.comm/Session.cpp @@ -109,7 +109,7 @@ void Session::initializeSequences() throw() { // affect any state that was set when the original request was // processed. Duplicate answer messages that are to be locally // consumed (see Section 6.2) SHOULD be silently discarded. - srand(::time(NULL) + anna::functions::exclusiveHash(anna::functions::asString("%s:%d|%d", getAddress().c_str(), getPort(), a_socketId))); + srand(::time(NULL) + anna::functions::hash(anna::functions::asString("%s:%d|%d", getAddress().c_str(), getPort(), a_socketId).c_str())); a_nextHopByHop = rand(); a_nextEndToEnd = ((::time(NULL) & 0xFFF) << 20) + (rand() & 0xFFFFF); } @@ -238,16 +238,20 @@ void Session::expireResponse(diameter::comm::Response* response) throw() { LOGMETHOD(anna::TraceMethod traceMethod("anna::diameter::comm::Session", "expireResponse", ANNA_FILE_LOCATION)); bool doUnbind = false; + bool doRetransmission = false; - // Quitar el OnExpiry: no tiene sentido habiendo keep-alive (DWR) if(response->getClassCode() != ClassCode::Bind) { if(response->getRequest()->getOnExpiry() == Message::OnExpiry::Abandon) { a_onDisconnect = OnDisconnect::IgnorePendings; // Abandon is not graceful doUnbind = true; } + else if(response->getRequest()->getOnExpiry() == Message::OnExpiry::Retransmit) { + doRetransmission = true; + } } else doUnbind = true; // (*) + try { response->setMessage(NULL); eventResponse(*response); @@ -263,6 +267,24 @@ throw() { setState(State::Bound); } + if(doRetransmission) { + diameter::comm::Message *request = const_cast(response->getRequest()); + int retries = request->getRetries(); + if (retries > 0) { + retries--; + request->setRetries(retries); + LOGDEBUG + ( + std::string msg(asString()); + msg += anna::functions::asString(" | Retransmission initiated for request with HopByHop: %u; remaining %d retries", response->getHopByHop(), retries); + anna::Logger::debug(msg, ANNA_FILE_LOCATION); + ); + diameter::codec::functions::setPotentiallyReTransmittedMessageBit(*request); + eventRequestRetransmission(request); + send(request); + } + } + response_erase(response); if(doUnbind) unbind(); @@ -275,7 +297,7 @@ void Session::finalize() throw() { cancelActionTimer(); // Action timer eventPeerShutdown(); /////////////////////////////////////////////////////////////////////// -// Notificar la finalización de las respuestas pendientes de recibir // +// Notificar la finalizaci�n de las respuestas pendientes de recibir // /////////////////////////////////////////////////////////////////////// // RFC 3588 - 5.5.4. Failover and Failback Procedures // @@ -417,7 +439,6 @@ throw() { // Messages anna::xml::Node* messages = result->createChild("diameter.comm.Messages"); - const Response* response; const Message* message; for(const_response_iterator ii = response_begin(), maxii = response_end(); ii != maxii; ii ++) { @@ -474,4 +495,3 @@ void Session::updateOutgoingActivityTime(void) throw() { anna::Logger::debug(msg, ANNA_FILE_LOCATION); ); } -