if (m_PendingBlocks_list.empty()) { CUpDownClient* slower_client = NULL; if (thePrefs::GetDropSlowSources()) { printf("Checking slower client from client %p\n",this); slower_client = m_reqfile->GetSlowerDownloadingClient(m_lastaverage, this); } if (slower_client == NULL) { slower_client = this; } if (!slower_client->GetSentCancelTransfer()) { CPacket* packet = new CPacket(OP_CANCELTRANSFER, 0, OP_EDONKEYPROT); theStats::AddUpOverheadFileRequest(packet->GetPacketSize()); if (slower_client != this) { printf("Dropped client %p to allow client %p to download\n",slower_client, this); } slower_client->ClearDownloadBlockRequests(); slower_client->SendPacket(packet,true,true); slower_client->SetSentCancelTransfer(1); } slower_client->SetDownloadState(DS_NONEEDEDPARTS); if (slower_client != this) { // Re-request freed blocks. AddDebugLogLineM( false, logLocalClient, wxT("Local Client: OP_CANCELTRANSFER (faster source eager to transfer) to ") + slower_client->GetFullIP() ); wxASSERT(m_DownloadBlocks_list.empty()); wxASSERT(m_PendingBlocks_list.empty()); uint16 count = m_MaxBlockRequests; Requested_Block_Struct* toadd[count]; if (m_reqfile->GetNextRequestedBlock(this,toadd,&count)) { for (int i = 0; i != count; i++) { Pending_Block_Struct* pblock = new Pending_Block_Struct; pblock->block = toadd[i]; pblock->zStream = NULL; pblock->totalUnzipped = 0; pblock->fZStreamError = 0; pblock->fRecovered = 0; m_PendingBlocks_list.push_back(pblock); } } else { // WTF, we just freed blocks. wxASSERT(0); return; } } else { // Drop this one. AddDebugLogLineM( false, logLocalClient, wxT("Local Client: OP_CANCELTRANSFER (no free blocks) to ") + GetFullIP() ); #warning Kry - Would be nice to swap A4AF here. return; } }