| 602 | return transfer; |
| 603 | } |
| 604 | void TUdpHost::SendLow(const TTransfer& transfer, TAutoPtr<TRopeDataPacket> data, EPacketPriority pp, const TTos& tos, ui8 netlibaColor) { |
| 605 | TConnection* connection = CheckedCast<TConnection*>(transfer.Connection.Get()); |
| 606 | std::pair<TUdpOutTransfer*, bool> p = connection->InsertSendTransfer(transfer.Id); // FailedSend needs created transfer |
| 607 | Connections.InsertToActive(connection); |
| 608 | Y_ASSERT(p.second); |
| 609 | |
| 610 | // shortcut for broken addresses or dead connection |
| 611 | if (connection->GetAddress().Port == 0) { |
| 612 | FailedSend(transfer); |
| 613 | return; |
| 614 | } |
| 615 | |
| 616 | Y_ASSERT(!connection->GetGuid().IsEmpty()); |
| 617 | |
| 618 | TPeerLink& peerInfo = connection->GetAlivePeerLink(); |
| 619 | |
| 620 | TUdpOutTransfer& xfer = *p.first; |
| 621 | xfer.Data.Reset(data.Release()); |
| 622 | xfer.AckTracker.AttachCongestionControl(peerInfo.GetUdpCongestion().Get()); |
| 623 | xfer.PacketPriority = pp; |
| 624 | xfer.DataTos = ChooseTos(tos.GetDataTos(), DefaultTos.GetDataTos()); |
| 625 | xfer.AckTos = ChooseTos(tos.GetAckTos(), DefaultTos.GetAckTos()); |
| 626 | xfer.NetlibaColor = netlibaColor; |
| 627 | xfer.AttachStats(TotalPendingDataStats); |
| 628 | xfer.AttachStats(ColoredPendingDataStats[netlibaColor]); |
| 629 | xfer.AttachStats(connection->GetStatsPtr()); |
| 630 | |
| 631 | // we don't support priorities (=service levels in IB terms) currently |
| 632 | // so send only PP_NORMAL traffic over IB |
| 633 | bool isSentOverIB = false; |
| 634 | TIntrusivePtr<IIBPeer> ibPeer = peerInfo.GetIBPeer(); |
| 635 | if (pp == PP_NORMAL && ibPeer.Get() && xfer.Data->GetSharedData() == nullptr) { |
| 636 | TGUID fakeUniqueGuid; |
| 637 | CreateGuid(&fakeUniqueGuid); |
| 638 | |
| 639 | TIBMsgHandle hndl = IB->Send(ibPeer, xfer.Data.Get(), fakeUniqueGuid, connection->GetGuid()); |
| 640 | //fprintf(stderr, "TUdpHost::Send\tIB->Send returned %" PRIi64 "\n", (i64)hndl); |
| 641 | |
| 642 | if (hndl >= 0) { |
| 643 | IBKeyToTransfer[hndl] = transfer; |
| 644 | isSentOverIB = true; |
| 645 | } else { |
| 646 | // so we failed to use IB, ibPeer is either not connected yet or failed |
| 647 | if (ibPeer->GetState() == IIBPeer::FAILED) { |
| 648 | //printf("Disconnect failed IB peer\n"); |
| 649 | peerInfo.SetIBPeer(nullptr); |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | if (!isSentOverIB) { |
| 654 | AddToSendOrder(transfer, pp); |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | void TUdpHost::AddToSendOrder(const TTransfer& transfer, EPacketPriority pp) { |
| 659 | if (pp == PP_LOW) |
nothing calls this directly
no test coverage detected