Browse Source

- BUGFIX: Fixed possible overflow in ETA calculation

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

1
TODO

@ -62,3 +62,4 @@ rc4->rc5 changelog: @@ -62,3 +62,4 @@ rc4->rc5 changelog:
- BUGFIX: Now filtered don't appear on hard drive anymore (libtorrent >= r1659)
- BUGFIX: AddInPause setting doesn't pause downloads on startup anymore
- 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() { @@ -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() { @@ -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.remove(hash);
} else {
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);
}
}
}

2
src/src.pro

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

Loading…
Cancel
Save