| 1045 | |
| 1046 | |
| 1047 | void CDownloadQueue::ProcessLocalRequests() |
| 1048 | { |
| 1049 | wxMutexLocker lock( m_mutex ); |
| 1050 | |
| 1051 | bool bServerSupportsLargeFiles = theApp->serverconnect |
| 1052 | && theApp->serverconnect->GetCurrentServer() |
| 1053 | && theApp->serverconnect->GetCurrentServer()->SupportsLargeFilesTCP(); |
| 1054 | |
| 1055 | if ( (!m_localServerReqQueue.empty()) && (m_dwNextTCPSrcReq < ::GetTickCount64()) ) { |
| 1056 | CMemFile dataTcpFrame(22); |
| 1057 | const int iMaxFilesPerTcpFrame = 15; |
| 1058 | int iFiles = 0; |
| 1059 | while (!m_localServerReqQueue.empty() && iFiles < iMaxFilesPerTcpFrame) { |
| 1060 | // find the file with the longest waitingtime |
| 1061 | uint64 dwBestWaitTime = 0xFFFFFFFFFFFFFFFF; |
| 1062 | |
| 1063 | std::list<CPartFile*>::iterator posNextRequest = m_localServerReqQueue.end(); |
| 1064 | std::list<CPartFile*>::iterator it = m_localServerReqQueue.begin(); |
| 1065 | while( it != m_localServerReqQueue.end() ) { |
| 1066 | CPartFile* cur_file = (*it); |
| 1067 | if (cur_file->GetStatus() == PS_READY || cur_file->GetStatus() == PS_EMPTY) { |
| 1068 | uint8 nPriority = cur_file->GetDownPriority(); |
| 1069 | if (nPriority > PR_HIGH) { |
| 1070 | wxFAIL; |
| 1071 | nPriority = PR_HIGH; |
| 1072 | } |
| 1073 | |
| 1074 | if (cur_file->GetLastSearchTime() + (PR_HIGH-nPriority) < dwBestWaitTime ){ |
| 1075 | dwBestWaitTime = cur_file->GetLastSearchTime() + (PR_HIGH - nPriority); |
| 1076 | posNextRequest = it; |
| 1077 | } |
| 1078 | |
| 1079 | ++it; |
| 1080 | } else { |
| 1081 | it = m_localServerReqQueue.erase(it); |
| 1082 | cur_file->SetLocalSrcRequestQueued(false); |
| 1083 | AddDebugLogLineN(logDownloadQueue, |
| 1084 | CFormat("Local server source request for file '%s' not sent because of status '%s'") |
| 1085 | % cur_file->GetFileName() % cur_file->getPartfileStatus()); |
| 1086 | } |
| 1087 | } |
| 1088 | |
| 1089 | if (posNextRequest != m_localServerReqQueue.end()) { |
| 1090 | CPartFile* cur_file = (*posNextRequest); |
| 1091 | cur_file->SetLocalSrcRequestQueued(false); |
| 1092 | cur_file->SetLastSearchTime(::GetTickCount64()); |
| 1093 | m_localServerReqQueue.erase(posNextRequest); |
| 1094 | iFiles++; |
| 1095 | |
| 1096 | if (!bServerSupportsLargeFiles && cur_file->IsLargeFile()) { |
| 1097 | AddDebugLogLineN(logDownloadQueue, "TCP Request for sources on a large file ignored: server doesn't support it"); |
| 1098 | } else { |
| 1099 | AddDebugLogLineN(logDownloadQueue, |
| 1100 | CFormat("Creating local sources request packet for '%s'") % cur_file->GetFileName()); |
| 1101 | // create request packet |
| 1102 | CMemFile data(16 + (cur_file->IsLargeFile() ? 8 : 4)); |
| 1103 | data.WriteHash(cur_file->GetFileHash()); |
| 1104 | // Kry - lugdunum extended protocol on 17.3 to handle filesize properly. |
nothing calls this directly
no test coverage detected