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

Method Process

src/PartFile.cpp:1488–1709  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1486}
1487
1488uint32 CPartFile::Process(uint8 m_icounter)
1489{
1490 // Partfiles have ~20 EC-exported fields that change frequently and
1491 // independently (status, speed, transfer counters, source counts, gap
1492 // list, hashed-part count, …). Per-field hooks have diminishing
1493 // returns when the file is actively transferring anyway, so use a
1494 // coarse mark here — Process() runs once per second per partfile and
1495 // the file genuinely has new state every tick during active download.
1496 MarkECChanged();
1497
1498 uint16 old_trans;
1499 uint64 dwCurTick = ::GetTickCount64();
1500
1501 // Flush on buffer-full, time-limit, or pending hash drain.
1502 // HasPendingHashWork() bypass drains Phase 3 at Process()-tick
1503 // rate (~100 ms) instead of every 60 s when the file is idle.
1504 if ( (m_nTotalBufferData > thePrefs::GetFileBufferSize()) ||
1505 (dwCurTick > (m_nLastBufferFlushTime + BUFFER_TIME_LIMIT)) ||
1506 HasPendingHashWork()) {
1507 FlushBuffer();
1508 }
1509
1510
1511 // check if we want new sources from server --> MOVED for 16.40 version
1512 old_trans=transferingsrc;
1513 transferingsrc = 0;
1514 kBpsDown = 0.0;
1515
1516 if (m_icounter < 10) {
1517 // Update only downloading sources.
1518 CClientRefList::iterator it = m_downloadingSourcesList.begin();
1519 for( ; it != m_downloadingSourcesList.end(); ) {
1520 CUpDownClient *cur_src = it++->GetClient();
1521 if(cur_src->GetDownloadState() == DS_DOWNLOADING) {
1522 ++transferingsrc;
1523 kBpsDown += cur_src->TickDownloadAndMeasure();
1524 }
1525 }
1526 } else {
1527 // Update all sources (including downloading sources)
1528 for ( SourceSet::iterator it = m_SrcList.begin(); it != m_SrcList.end(); ) {
1529 CUpDownClient* cur_src = it++->GetClient();
1530 switch (cur_src->GetDownloadState()) {
1531 case DS_DOWNLOADING: {
1532 ++transferingsrc;
1533 kBpsDown += cur_src->TickDownloadAndMeasure();
1534 break;
1535 }
1536 case DS_BANNED: {
1537 break;
1538 }
1539 case DS_ERROR: {
1540 break;
1541 }
1542 case DS_LOWTOLOWIP: {
1543 if (cur_src->HasLowID() && !theApp->CanDoCallback(cur_src->GetServerIP(), cur_src->GetServerPort())) {
1544 // If we are almost maxed on sources,
1545 // slowly remove these client to see

Callers 2

OnCoreTimerMethod · 0.45
ConnectToAnyServerMethod · 0.45

Calls 15

GetTickCount64Function · 0.85
CFormatClass · 0.85
CanDoCallbackMethod · 0.80
SetDownloadStateMethod · 0.80
GetLastAskedTimeMethod · 0.80
UDPReaskForDownloadMethod · 0.80
AskForDownloadMethod · 0.80
IsA4AFAutoMethod · 0.80
DoKademliaFileRequestMethod · 0.80
SendLocalSrcRequestMethod · 0.80

Tested by

no test coverage detected