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

Method CheckForTimeOver

src/UploadQueue.cpp:571–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

569
570
571bool CUploadQueue::CheckForTimeOver(CUpDownClient* client)
572{
573 // Don't kick anybody if there's no need to
574 if (!m_allowKicking) {
575 return false;
576 }
577 // First, check if it is a VIP slot (friend or Release-Prio).
578 if (client->GetFriendSlot()) {
579 return false; // never drop the friend
580 }
581 // Release-Prio and nobody on queue for it?
582 if (client->GetUploadFile()->GetUpPriority() == PR_POWERSHARE) {
583 // Keep it unless half of the UL slots are occupied with friends or Release uploads.
584 uint16 vips = 0;
585 for (CClientRefList::iterator it = m_uploadinglist.begin(); it != m_uploadinglist.end(); ++it) {
586 CUpDownClient* cur_client = it->GetClient();
587 if (cur_client->GetFriendSlot() || cur_client->GetUploadFile()->GetUpPriority() == PR_POWERSHARE) {
588 vips++;
589 }
590 }
591 // allow if VIP uploads occupy at most half of the possible upload slots
592 if (vips <= GetMaxSlots() / 2) {
593 return false;
594 }
595 // Otherwise normal rules apply.
596 }
597
598 // Ordinary slots
599 // "Transfer full chunks": drop client after 10 MB upload, or after an hour.
600 // (so average UL speed should at least be 2.84 kB/s)
601 // We don't track what he is downloading, but if it's all from one chunk he gets it.
602 if (client->GetUpStartTimeDelay() > 3600000 // time: 1h
603 || client->GetSessionUp() > 10485760) { // data: 10MB
604 m_allowKicking = false; // kick max one client per cycle
605 return true;
606 }
607
608 return false;
609}
610
611
612/*

Callers 1

SendBlockDataMethod · 0.80

Calls 8

GetUpPriorityMethod · 0.80
GetUpStartTimeDelayMethod · 0.80
GetSessionUpMethod · 0.80
GetFriendSlotMethod · 0.45
GetUploadFileMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetClientMethod · 0.45

Tested by

no test coverage detected