| 739 | } |
| 740 | |
| 741 | void CUpDownClient::ProcessRequestPartsPacketv2(const CMemFile& data) { |
| 742 | |
| 743 | CMD4Hash reqfilehash = data.ReadHash(); |
| 744 | |
| 745 | uint8 numblocks = data.ReadUInt8(); |
| 746 | |
| 747 | for (int i = 0; i < numblocks; i++) { |
| 748 | Requested_Block_Struct* reqblock = new Requested_Block_Struct; |
| 749 | try { |
| 750 | reqblock->StartOffset = data.GetIntTagValue(); |
| 751 | // We have to do +1, because the block matching uses that. |
| 752 | reqblock->EndOffset = data.GetIntTagValue() + 1; |
| 753 | if ((reqblock->StartOffset || reqblock->EndOffset) && (reqblock->StartOffset > reqblock->EndOffset)) { |
| 754 | AddDebugLogLineN(logClient, CFormat("Client %s request is invalid! %d / %d") |
| 755 | % GetFullIP() % reqblock->StartOffset % reqblock->EndOffset); |
| 756 | throw wxString("Client request is invalid!"); |
| 757 | } |
| 758 | |
| 759 | AddDebugLogLineN(logClient, |
| 760 | CFormat("Client %s requests %d File block %d-%d (%d bytes):") |
| 761 | % GetFullIP() % i % reqblock->StartOffset % reqblock->EndOffset |
| 762 | % (reqblock->EndOffset - reqblock->StartOffset)); |
| 763 | |
| 764 | md4cpy(reqblock->FileID, reqfilehash.GetHash()); |
| 765 | reqblock->transferred = 0; |
| 766 | AddReqBlock(reqblock, false); |
| 767 | } catch (...) { |
| 768 | delete reqblock; |
| 769 | throw; |
| 770 | } |
| 771 | } |
| 772 | if (theApp->uploadDiskIOThread) { |
| 773 | theApp->uploadDiskIOThread->NewBlockRequestsAvailable(); |
| 774 | } |
| 775 | } |
| 776 | // File_checked_for_headers |
no test coverage detected