| 775 | } |
| 776 | |
| 777 | bool TUdpHost::SendCycle(ui8 prio) { |
| 778 | bool res1 = Connections.ForEachSendingConnection([prio, this](TSendingConnectionsList::iterator& sc) { |
| 779 | typedef TConnections::ESentConnectionResult TSentConnectionResult; |
| 780 | TConnection* connection = sc->Get(); |
| 781 | TDeque<ui64>& transferIdQueue = connection->GetSendingTransfers(prio); |
| 782 | for (TDeque<ui64>::iterator z = transferIdQueue.begin(); z != transferIdQueue.end();) { |
| 783 | const ui64 transferId = *z; |
| 784 | TUdpOutTransfer* xfer = connection->GetSendQueue().Get(transferId); |
| 785 | if (!xfer) { |
| 786 | z = transferIdQueue.erase(z); |
| 787 | if (transferIdQueue.empty()) { |
| 788 | return connection->HasAnySendingTransfers() ? TSentConnectionResult::SCR_CONT : TSentConnectionResult::SCR_DELETE; //delete connection if all queues are empty |
| 789 | } else { |
| 790 | continue; |
| 791 | } |
| 792 | } else { |
| 793 | Y_ASSERT(connection->IsAlive()); |
| 794 | } |
| 795 | const float deltaT = (float)NHPTimer::GetSeconds(CurrentT - xfer->LastTime); |
| 796 | xfer->LastTime = CurrentT; |
| 797 | |
| 798 | if (!xfer->AckTracker.IsInitialized()) { |
| 799 | // Cerr << GetAddressAsString(connection->GetAddress()) << " Checking MTU for conn=" << ui64(connection) << ", xfer=" << ui64(xfer) << Endl; |
| 800 | if (!CheckMTU(connection, *xfer)) { |
| 801 | return TSentConnectionResult::SCR_CONT; //if we can`t get MTU for transfer we can`t get for connection |
| 802 | } |
| 803 | xfer->InitXfer(); |
| 804 | } |
| 805 | xfer->AckTracker.Step(deltaT); |
| 806 | MaxWaitTime = Min(MaxWaitTime, xfer->AckTracker.GetTimeToNextPacketTimeout()); |
| 807 | |
| 808 | for (;;) { |
| 809 | if (!xfer->AckTracker.CanSend()) { |
| 810 | if (xfer->TriedToSendAtLeastOnePacket) { |
| 811 | //we can`t stop iteration if we start sending |
| 812 | break; |
| 813 | } |
| 814 | return TSentConnectionResult::SCR_CONT; //we can`t send more for current connection |
| 815 | } |
| 816 | TUdpHost::ESentPacketResult res2 = SendTransferPacket(connection, xfer, transferId); |
| 817 | if (res2 == TUdpHost::ESentPacketResult::SPR_STOP_SENDING_TRANSFER) { |
| 818 | break; |
| 819 | } else if (res2 == TUdpHost::ESentPacketResult::SPR_OVERFLOW) { |
| 820 | return TSentConnectionResult::SCR_BREAK; |
| 821 | } |
| 822 | } |
| 823 | ++z; |
| 824 | } |
| 825 | return TSentConnectionResult::SCR_CONT; |
| 826 | }); |
| 827 | FlushPackets(); |
| 828 | return res1; |
| 829 | } |
| 830 | |
| 831 | //Calls FlushPackets and checks status of current xfer |
| 832 | //if got FPR_OUT_TRANSFERS_CHANGED for current xfer - current xfer is invalid. Return errors |
nothing calls this directly
no test coverage detected