MCPcopy Create free account
hub / github.com/catboost/catboost / Send

Method Send

library/cpp/netliba/v6/udp_client_server.cpp:378–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376 }
377
378 int Send(const TUdpAddress& addr, TAutoPtr<TRopeDataPacket> data, int crc32, TGUID* packetGuid, EPacketPriority pp) override {
379 if (addr.Port == 0) {
380 // shortcut for broken addresses
381 if (packetGuid && packetGuid->IsEmpty())
382 CreateGuid(packetGuid);
383 int reqId = GetTransferId();
384 FailedSend(reqId);
385 return reqId;
386 }
387 TTransferKey transferKey;
388 transferKey.Address = addr;
389 transferKey.Id = GetTransferId();
390 Y_ASSERT(SendQueue.find(transferKey) == SendQueue.end());
391
392 TPeerLink& peerInfo = GetPeerLink(transferKey.Address);
393
394 TUdpOutTransfer& xfer = SendQueue[transferKey];
395 GetWinsockAddr(&xfer.ToAddress, transferKey.Address);
396 xfer.Crc32 = crc32;
397 xfer.PacketPriority = pp;
398 if (!packetGuid || packetGuid->IsEmpty()) {
399 CreateGuid(&xfer.PacketGuid);
400 if (packetGuid)
401 *packetGuid = xfer.PacketGuid;
402 } else {
403 xfer.PacketGuid = *packetGuid;
404 }
405 xfer.Data.Reset(data.Release());
406 xfer.AttachStats(&PendingDataStats);
407 xfer.AckTracker.AttachCongestionControl(peerInfo.UdpCongestion.Get());
408
409 bool isSentOverIB = false;
410 // we don't support priorities (=service levels in IB terms) currently
411 // so send only PP_NORMAL traffic over IB
412 if (pp == PP_NORMAL && peerInfo.IBPeer.Get() && xfer.Data->GetSharedData() == nullptr) {
413 TIBMsgHandle hndl = IB->Send(peerInfo.IBPeer, xfer.Data.Get(), xfer.PacketGuid);
414 if (hndl >= 0) {
415 IBKeyToTransferKey[hndl] = transferKey;
416 isSentOverIB = true;
417 } else {
418 // so we failed to use IB, ibPeer is either not connected yet or failed
419 if (peerInfo.IBPeer->GetState() == IIBPeer::FAILED) {
420 //printf("Disconnect failed IB peer\n");
421 peerInfo.IBPeer = nullptr;
422 }
423 }
424 }
425 if (!isSentOverIB) {
426 AddToSendOrder(transferKey, pp);
427 }
428
429 return transferKey.Id;
430 }
431
432 bool GetSendResult(TSendResult* res) override {
433 if (SendResults.empty()) {

Callers

nothing calls this directly

Calls 13

CreateGuidFunction · 0.85
GetTransferIdFunction · 0.85
GetWinsockAddrFunction · 0.70
IsEmptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
ResetMethod · 0.45
ReleaseMethod · 0.45
AttachStatsMethod · 0.45
GetMethod · 0.45
GetSharedDataMethod · 0.45

Tested by

no test coverage detected