MCPcopy Create free account
hub / github.com/amule-project/amule / Process

Method Process

src/UploadQueue.cpp:239–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239void CUploadQueue::Process()
240{
241 // Check if someone's waiting, if there is a slot for him,
242 // or if we should try to free a slot for him
243 uint64 tick = GetTickCount64();
244 // Nobody waiting or upload started recently
245 // (Actually instead of "empty" it should check for "no HighID clients queued",
246 // but the cost for that outweighs the benefit. As it is, a slot will be freed
247 // even if it can't be taken because all of the queue is LowID. But just one,
248 // and the kicked client will instantly get it back if he has HighID.)
249 // Also, if we are running out of sockets, don't add new clients, but also don't kick existing ones,
250 // or uploading will cease right away.
251#if EXTENDED_UPLOADQUEUE
252 if (tick - m_nLastStartUpload < 1000
253#else
254 if (m_waitinglist.empty() || tick - m_nLastStartUpload < 1000
255#endif
256 || theApp->listensocket->TooManySockets()) {
257 m_allowKicking = false;
258 // Already a slot free, try to fill it
259 } else if (m_uploadinglist.size() < GetMaxSlots()) {
260 m_allowKicking = false;
261 m_nLastStartUpload = tick;
262 AddUpNextClient();
263 // All slots taken, try to free one
264 } else {
265 m_allowKicking = true;
266 }
267
268 // The loop that feeds the upload slots with data.
269 CClientRefList::iterator it = m_uploadinglist.begin();
270 while (it != m_uploadinglist.end()) {
271 // Get the client. Note! Also updates pos as a side effect.
272 CUpDownClient* cur_client = it++->GetClient();
273
274 // It seems chatting or friend slots can get stuck at times in upload.. This needs looked into..
275 if (!cur_client->GetSocket()) {
276 RemoveFromUploadQueue(cur_client);
277 if(cur_client->Disconnected(_T("CUploadQueue::Process"))){
278 cur_client->Safe_Delete();
279 }
280 } else if (cur_client->m_bIOError) {
281 // Disk I/O thread signaled an error for this client
282 RemoveFromUploadQueue(cur_client);
283 } else {
284 cur_client->SendBlockData();
285 }
286 }
287
288 // Save used bandwidth for speed calculations
289 uint64 sentBytes = theApp->uploadBandwidthThrottler->GetNumberOfSentBytesSinceLastCallAndReset();

Callers

nothing calls this directly

Calls 12

GetTickCount64Function · 0.85
ifFunction · 0.85
TooManySocketsMethod · 0.80
GetSocketMethod · 0.80
DisconnectedMethod · 0.80
SendBlockDataMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
GetClientMethod · 0.45
Safe_DeleteMethod · 0.45

Tested by

no test coverage detected