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

Method AddClientToQueue

src/UploadQueue.cpp:396–533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394
395
396void CUploadQueue::AddClientToQueue(CUpDownClient* client)
397{
398 if (theApp->serverconnect->IsConnected() && theApp->serverconnect->IsLowID() && !theApp->serverconnect->IsLocalServer(client->GetServerIP(),client->GetServerPort()) && client->GetDownloadState() == DS_NONE && !client->IsFriend() && theStats::GetWaitingUserCount() > 50) {
399 // Well, all that issues finish in the same: don't allow to add to the queue
400 return;
401 }
402
403 if ( client->IsBanned() ) {
404 return;
405 }
406
407 client->AddAskedCount();
408 client->SetLastUpRequest();
409
410 // Find all clients with the same user-hash
411 CClientList::SourceList found = theApp->clientlist->GetClientsByHash( client->GetUserHash() );
412
413 CClientList::SourceList::iterator it = found.begin();
414 while (it != found.end()) {
415 CUpDownClient* cur_client = it++->GetClient();
416
417 if ( IsOnUploadQueue( cur_client ) ) {
418 if ( cur_client == client ) {
419 // This is where LowID clients get their upload slot assigned.
420 // They can't be contacted if they reach top of the queue, so they are just marked for uploading.
421 // When they reconnect next time AddClientToQueue() is called, and they get their slot
422 // through the connection they initiated.
423 // Since at that time no slot is free they get assigned an extra slot,
424 // so then the number of slots exceeds the configured number by one.
425 // To prevent a further increase no more LowID clients get a slot, until
426 // - a HighID client has got one (which happens only after two clients
427 // have been kicked so a slot is free again)
428 // - or there is a free slot, which means there is no HighID client on queue
429 if (client->m_bAddNextConnect) {
430 uint32 maxSlots = GetMaxSlots();
431 if (lastupslotHighID) {
432 maxSlots++;
433 }
434 if (m_uploadinglist.size() < maxSlots) {
435 client->m_bAddNextConnect = false;
436 RemoveFromWaitingQueue(client);
437 AddUpNextClient(client);
438 lastupslotHighID = false; // LowID alternate
439 return;
440 }
441 }
442
443 client->SendRankingInfo();
444 Notify_SharedCtrlRefreshClient(client->ECID(), AVAILABLE_SOURCE);
445 return;
446 } else {
447 // Hash-clash, remove unidentified clients (possibly both)
448
449 if ( !cur_client->IsIdentified() ) {
450 // Cur_client isn't identifed, remove it
451 theApp->clientlist->AddTrackClient( cur_client );
452
453 RemoveFromWaitingQueue( cur_client );

Callers 2

ProcessPacketMethod · 0.80

Calls 15

GetTickCount64Function · 0.85
IsLocalServerMethod · 0.80
IsBannedMethod · 0.80
AddAskedCountMethod · 0.80
SetLastUpRequestMethod · 0.80
GetClientsByHashMethod · 0.80
SendRankingInfoMethod · 0.80
ECIDMethod · 0.80
AddTrackClientMethod · 0.80
GetSocketMethod · 0.80
DisconnectedMethod · 0.80
GetClientsByIPMethod · 0.80

Tested by

no test coverage detected