const char * MessageRequestScheduler::FragReqWrapper::getGroupName() const { if (pFRequests != NULL) { MessageHeader *pMH = pFRequests->pMsgHeader; if (pMH != NULL) { return pMH->getGroupName(); } } return NULL; }
PtrLList<Message> * NetworkTrafficMemory::filterRecentlySent (Message *pMsg, int64 i64RequestArrivalTime) { _m.lock (186); MessageHeader *pMH = pMsg->getMessageHeader(); if (pMH == NULL) { checkAndLogMsg ("NetworkTrafficMemory::filterRecentlySent", Logger::L_Warning, "Message object does not contain message header.\n"); } PtrLList<Message> *pRet = new PtrLList<Message>(); if (pRet == NULL) { checkAndLogMsg ("NetworkTrafficMemory::filterRecentlySent", memoryExhausted); _m.unlock (186); return NULL; } if (_ui16IgnoreRequestTime == 0) { pRet->insert (new Message (pMH->clone(), pMsg->getData())); _m.unlock (186); return pRet; } MessagesByGroup *pBG = _messageByGroup.get (pMH->getGroupName()); if (pBG == NULL) { pRet->insert (new Message (pMH->clone(), pMsg->getData())); _m.unlock (186); return pRet; } MessagesBySender *pMS = pBG->messageBySender.get (pMH->getPublisherNodeId()); if (pMS == NULL) { pRet->insert (new Message (pMH->clone(), pMsg->getData())); _m.unlock (186); return pRet; } FragmentedMessageHeader *pFMH = pMS->messageBySeqId.get (pMH->getMsgSeqId()); if (pFMH == NULL) { pRet->insert (new Message (pMH->clone(), pMsg->getData())); _m.unlock (186); return pRet; } if (pMH->isChunk()) { FragmentedChunk *pFC = ((FragmentedMessage *) pFMH)->chunksByChunkId.get (pMsg->getChunkMsgInfo()->getChunkId()); if (pFC == NULL) { pRet->insert (new Message (pMH->clone(), pMsg->getData())); _m.unlock (186); return pRet; } else { pFMH = pFC; } } char *psFragToSendData; psFragToSendData = (char *) pMsg->getData(); uint32 ui32FragToSendStart = pMH->getFragmentOffset(); uint32 ui32FragToSendEnd = ui32FragToSendStart + pMH->getFragmentLength(); MessageHeader *pTmpMI; for (FragmentWrapper *pFW = pFMH->fragments.getFirst(); (pFW != NULL) && (ui32FragToSendEnd > pFW->ui32Offset); pFW = pFMH->fragments.getNext()) { if (pFW->overlaps (ui32FragToSendStart, ui32FragToSendEnd)) { if ((i64RequestArrivalTime - pFW->i64LastServingTime) < _ui16IgnoreRequestTime) { // I need to split // write everything before pFW->ui32Offset uint32 ui32TmpFragLength = (ui32FragToSendStart < pFW->ui32Offset ? pFW->ui32Offset - ui32FragToSendStart : (uint32) 0); if (ui32TmpFragLength > 0) { pTmpMI = pMH->clone(); pTmpMI->setFragmentOffset (ui32FragToSendStart); pTmpMI->setFragmentLength (ui32TmpFragLength); pRet->insert (new Message (pTmpMI, psFragToSendData)); } // ui32FragToSendStart = pFW->ui32End; // psFragToSendData = psFragToSendData + ui32TmpFragLength; ui32TmpFragLength = minimum (pFW->ui32End, ui32FragToSendEnd) - ui32FragToSendStart; ui32FragToSendStart += ui32TmpFragLength; psFragToSendData += ui32TmpFragLength; } } } // Add the remaining part if (ui32FragToSendStart < ui32FragToSendEnd) { pTmpMI = pMH->clone(); pTmpMI->setFragmentOffset (ui32FragToSendStart); pTmpMI->setFragmentLength (ui32FragToSendEnd - ui32FragToSendStart); pRet->insert (new Message (pTmpMI, psFragToSendData)); } _m.unlock (186); return pRet; }