| 407 | // x > NORMALITY_FACTOR -> High availability. |
| 408 | |
| 409 | void CDownloadQueue::Process() |
| 410 | { |
| 411 | // send src requests to local server |
| 412 | ProcessLocalRequests(); |
| 413 | const uint64 curTick = ::GetTickCount64(); |
| 414 | { |
| 415 | wxMutexLocker lock(m_mutex); |
| 416 | |
| 417 | // Refill the global download bucket for this tick. The previous |
| 418 | // per-peer ratio controller (50-200% adaptive against the |
| 419 | // observed aggregate datarate) never actually enforced |
| 420 | // MaxDownload as a literal byte/sec cap. The throttler is a |
| 421 | // single shared atomic budget that every CEMSocket consults |
| 422 | // before each Read(); fast peers can claim unused capacity |
| 423 | // from slow ones within the same tick (demand-aware |
| 424 | // redistribution), and the global cap is the only constraint. |
| 425 | // MaxDownload=0 (UNLIMITED) sets the throttler to bypass mode. |
| 426 | CDownloadBandwidthThrottler::Get().RefillBudget( |
| 427 | thePrefs::GetMaxDownload(), CORE_TIMER_PERIOD); |
| 428 | |
| 429 | m_datarate = 0; |
| 430 | m_udcounter++; |
| 431 | uint32 cur_datarate = 0; |
| 432 | uint32 cur_udcounter = m_udcounter; |
| 433 | |
| 434 | std::list<int> m_sourcecountlist; |
| 435 | |
| 436 | bool mustPreventSleep = false; |
| 437 | |
| 438 | for ( FileQueue::size_type i = 0; i < m_filelist.size(); i++ ) { |
| 439 | CPartFile* file = m_filelist[i]; |
| 440 | |
| 441 | CMutexUnlocker unlocker(m_mutex); |
| 442 | |
| 443 | uint8 status = file->GetStatus(); |
| 444 | mustPreventSleep |= !(status == PS_ERROR || status == PS_INSUFFICIENT || status == PS_PAUSED || status == PS_COMPLETE); |
| 445 | |
| 446 | if (status == PS_READY || status == PS_EMPTY ){ |
| 447 | cur_datarate += file->Process( cur_udcounter ); |
| 448 | } else { |
| 449 | //This will make sure we don't keep old sources to paused and stopped files.. |
| 450 | file->StopPausedFile(); |
| 451 | |
| 452 | // Drain leftover Phase 3 hash work for paused files: their |
| 453 | // Process() doesn't run (gated above), but pre-pause |
| 454 | // m_aChangedPart entries still need verification. |
| 455 | // |
| 456 | // PS_INSUFFICIENT is intentionally excluded — driving |
| 457 | // FlushBuffer for a disk-full file re-enters its disk-space |
| 458 | // check at PartFile.cpp:3083 every tick, which logs |
| 459 | // "Not enough free disk-space" and re-pauses on every call, |
| 460 | // producing tens of log lines per second. The destructor |
| 461 | // sync-hash drain still covers leftover dirty parts of |
| 462 | // disk-full files at shutdown. |
| 463 | if (status == PS_PAUSED && file->HasPendingHashWork()) { |
| 464 | file->FlushBuffer(); |
| 465 | } |
| 466 | } |
nothing calls this directly
no test coverage detected