| 1338 | } |
| 1339 | |
| 1340 | bool TUdpHost::ProcessCancelTransferPacket(const EUdpCmd cmd, const char*, const char*, const TTransfer& transfer, TConnection* connection) { |
| 1341 | switch (cmd) { |
| 1342 | case CANCEL_TRANSFER: { |
| 1343 | bool isFailed, isCanceled; |
| 1344 | |
| 1345 | ui8 tos = DefaultTos.GetAckTos(); |
| 1346 | TUdpInTransfer* xferPtr = connection->GetRecvQueue().Get(transfer.Id); |
| 1347 | |
| 1348 | // there is an active transfer |
| 1349 | if (xferPtr) { |
| 1350 | tos = xferPtr->AckTos; |
| 1351 | connection->CanceledRecvTransfer(transfer.Id); |
| 1352 | |
| 1353 | // transfer is finished or has not been started yet |
| 1354 | } else { |
| 1355 | // may be we have not received any packet of this transfer, maybe we successfully received it, maybe we cancelled it... |
| 1356 | const bool isCompleted = connection->IsRecvCompleted(transfer.Id, &isFailed, &isCanceled); |
| 1357 | |
| 1358 | // already successfully received it or it failed or it was previously canceled |
| 1359 | if (isCompleted) { |
| 1360 | if (!isFailed && !isCanceled) { |
| 1361 | SendAckComplete(S, connection, transfer.Id, -1, tos); |
| 1362 | return true; |
| 1363 | } else if (isFailed) { |
| 1364 | // ignore |
| 1365 | return true; |
| 1366 | } |
| 1367 | Y_ASSERT(isCanceled); |
| 1368 | |
| 1369 | // we never received any packet of this transfer! |
| 1370 | } else { |
| 1371 | std::pair<TUdpInTransfer*, bool> p = connection->InsertRecvTransfer(transfer.Id); |
| 1372 | Y_ASSERT(p.second); |
| 1373 | connection->CanceledRecvTransfer(transfer.Id); |
| 1374 | Connections.InsertToActive(connection); |
| 1375 | } |
| 1376 | } |
| 1377 | |
| 1378 | // we will ignore upcoming packets and response with ACK_CANCELED on them |
| 1379 | Y_ASSERT(connection->IsRecvCompleted(transfer.Id, &isFailed, &isCanceled) && isCanceled); |
| 1380 | |
| 1381 | SendAckCanceled(S, connection, transfer.Id, -1, tos); // we always answer even if it's duplicate packet |
| 1382 | return true; |
| 1383 | } |
| 1384 | default: |
| 1385 | break; |
| 1386 | } |
| 1387 | Y_ASSERT(0 && "Not a cancel transfer cmd!"); |
| 1388 | return false; |
| 1389 | } |
| 1390 | |
| 1391 | bool TUdpHost::ProcessPingPacket(const EUdpCmd cmd, const char* pktData, const char* pktEnd, const sockaddr_in6& fromAddress, |
| 1392 | TConnection* connection) { |
nothing calls this directly
no test coverage detected