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

Method ProcessDataPacket

library/cpp/netliba/v12/udp_host.cpp:1136–1275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1134 }
1135
1136 bool TUdpHost::ProcessDataPacket(const EUdpCmd cmd, const char* pktData, const char* pktEnd,
1137 TAutoPtr<TUdpRecvPacket> recvBuf, const TTransfer& transfer, const TOptionsVector& opt) {
1138 Y_ASSERT(IsDataCmd(cmd));
1139 Y_ASSERT(pktData <= pktEnd);
1140
1141 int packetId;
1142 int ackTos;
1143 ui8 netlibaColor;
1144
1145 if (!ReadPacketHeaderTail(&pktData, pktEnd, &packetId, &ackTos, &netlibaColor, opt) || packetId < 0 || !IsValidTos(ackTos)) {
1146 Y_ASSERT(false);
1147 return false;
1148 }
1149
1150 TConnection* connection = CheckedCast<TConnection*>(transfer.Connection.Get());
1151 Connections.InsertToActive(connection);
1152 bool isFailed = false, isCanceled = false;
1153 if (connection->IsRecvCompleted(transfer.Id, &isFailed, &isCanceled)) {
1154 Y_ASSERT(!connection->GetRecvQueue().Has(transfer.Id));
1155
1156 if (isCanceled) {
1157 SendAckCanceled(S, connection, transfer.Id, packetId, DefaultTos.GetAckTos());
1158 } else if (isFailed) {
1159 ; // TODO: we cannot continue, at least we must reset everything, maybe ignore?
1160 } else {
1161 SendAckComplete(S, connection, transfer.Id, packetId, DefaultTos.GetAckTos()); // TODO: where to get ack tos?
1162 }
1163 return true;
1164 }
1165
1166 std::pair<TUdpInTransfer*, bool> p = connection->InsertRecvTransfer(transfer.Id);
1167 if (p.second) {
1168 //printf("new input transfer\n");
1169 TUdpInTransfer& res = *p.first;
1170 res.AckTos = ChooseTos(ackTos, DefaultTos.GetAckTos());
1171 res.NetlibaColor = netlibaColor;
1172 res.HighPriority = opt.TransferOpt.IsHighPriority();
1173 res.PacketSize = 0;
1174 res.HasLastPacket = false;
1175 res.AttachStats(TotalPendingDataStats);
1176 res.AttachStats(ColoredPendingDataStats[netlibaColor]);
1177 res.AttachStats(connection->GetStatsPtr());
1178 }
1179 TUdpInTransfer& xfer = *p.first;
1180 xfer.TimeSinceLastRecv = 0;
1181
1182 // got duplicate packet
1183 if (packetId < xfer.GetPacketCount() && xfer.GetPacket(packetId)) {
1184 xfer.NewPacketsToAck.push_back(packetId);
1185 return true;
1186 }
1187
1188 if (!ReadDataPacket(cmd, &pktData, pktEnd, packetId, &xfer.SharedData, &xfer.PacketSize, opt)) {
1189 if (opt.TransferOpt.IsSharedMemoryRequired() && xfer.SharedData.Get() && !xfer.SharedData->GetPtr()) {
1190 SendAckResendNoShmem(S, connection, transfer.Id, DefaultTos.GetAckTos());
1191 }
1192 Y_ASSERT(false);
1193 return false;

Callers

nothing calls this directly

Calls 15

IsDataCmdFunction · 0.85
ReadPacketHeaderTailFunction · 0.85
IsValidTosFunction · 0.85
SendAckCanceledFunction · 0.85
SendAckCompleteFunction · 0.85
ChooseTosFunction · 0.85
ReadDataPacketFunction · 0.85
SendAckResendNoShmemFunction · 0.85
InsertToActiveMethod · 0.80
IsRecvCompletedMethod · 0.80
GetAckTosMethod · 0.80
InsertRecvTransferMethod · 0.80

Tested by

no test coverage detected