mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-15 01:33:07 -07:00
- BUGFIX: Fixed possible overflow in ETA calculation
This commit is contained in:
parent
9bb18e1a07
commit
f754e34e35
3 changed files with 14 additions and 7 deletions
|
@ -147,7 +147,9 @@ void bittorrent::updateETAs() {
|
|||
if(listEtas.size() == ETAS_MAX_VALUES) {
|
||||
listEtas.removeFirst();
|
||||
}
|
||||
if(h.download_payload_rate()) {
|
||||
// XXX: We can still get an overflow if remaining file size is approximately
|
||||
// 8.38*10^5 TiB (lets assume this can't happen)
|
||||
if(h.download_payload_rate() > 0.1) {
|
||||
listEtas << (qlonglong)((h.actual_size()-h.total_wanted_done())/(double)h.download_payload_rate());
|
||||
ETAstats[hash] = listEtas;
|
||||
qlonglong moy = 0;
|
||||
|
@ -156,12 +158,16 @@ void bittorrent::updateETAs() {
|
|||
Q_ASSERT(nbETAs);
|
||||
foreach(val, listEtas) {
|
||||
moy += (qlonglong)((double)val/(double)nbETAs);
|
||||
if(moy < 0) break;
|
||||
Q_ASSERT(moy >= 0);
|
||||
}
|
||||
if(moy < 0) {
|
||||
ETAs[hash] = moy;
|
||||
} else {
|
||||
// Speed is too low, we don't want overflow.
|
||||
if(ETAstats.contains(hash)) {
|
||||
ETAs.remove(hash);
|
||||
}
|
||||
if(ETAs.contains(hash)) {
|
||||
ETAs.remove(hash);
|
||||
} else {
|
||||
ETAs[hash] = moy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue