Browse Source

- BUGFIX: Fixed possible overflow in ETA calculation

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
f754e34e35
  1. 3
      TODO
  2. 16
      src/bittorrent.cpp
  3. 2
      src/src.pro

3
TODO

@ -61,4 +61,5 @@
rc4->rc5 changelog: rc4->rc5 changelog:
- BUGFIX: Now filtered don't appear on hard drive anymore (libtorrent >= r1659) - BUGFIX: Now filtered don't appear on hard drive anymore (libtorrent >= r1659)
- BUGFIX: AddInPause setting doesn't pause downloads on startup anymore - BUGFIX: AddInPause setting doesn't pause downloads on startup anymore
- BUGFIX: Fixed an ETA calculation problem when the torrent has filtered files - BUGFIX: Fixed an ETA calculation problem when the torrent has filtered files
- BUGFIX: Fixed possible overflow in ETA calculation

16
src/bittorrent.cpp

@ -147,7 +147,9 @@ void bittorrent::updateETAs() {
if(listEtas.size() == ETAS_MAX_VALUES) { if(listEtas.size() == ETAS_MAX_VALUES) {
listEtas.removeFirst(); 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()); listEtas << (qlonglong)((h.actual_size()-h.total_wanted_done())/(double)h.download_payload_rate());
ETAstats[hash] = listEtas; ETAstats[hash] = listEtas;
qlonglong moy = 0; qlonglong moy = 0;
@ -156,12 +158,16 @@ void bittorrent::updateETAs() {
Q_ASSERT(nbETAs); Q_ASSERT(nbETAs);
foreach(val, listEtas) { foreach(val, listEtas) {
moy += (qlonglong)((double)val/(double)nbETAs); 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); ETAs.remove(hash);
} else {
ETAs[hash] = moy;
} }
} }
} }

2
src/src.pro

@ -11,7 +11,7 @@ TARGET = qbittorrent
CONFIG += qt thread x11 network CONFIG += qt thread x11 network
# Update this VERSION for each release # Update this VERSION for each release
DEFINES += VERSION=\\\"v1.0.0rc4\\\" DEFINES += VERSION=\\\"v1.0.0rc5\\\"
DEFINES += VERSION_MAJOR=1 DEFINES += VERSION_MAJOR=1
DEFINES += VERSION_MINOR=0 DEFINES += VERSION_MINOR=0
DEFINES += VERSION_BUGFIX=0 DEFINES += VERSION_BUGFIX=0

Loading…
Cancel
Save