Browse Source

- Fixed overflow that caused ratio to become negative

- Added some more asserts so that it doesn't happen again
- Fixed waiting for paused_alert on exit in the case where a torrent was paused then resumed before we received torrent_paused_alert
adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
44d61e0b9d
  1. 8
      TODO
  2. 22
      src/bittorrent.cpp
  3. 2
      src/properties_imp.cpp

8
TODO

@ -1,9 +1,10 @@
// Easy // Easy
- Translations into as many languages as possible - Translations into as many languages as possible
- Improve man page - Improve man page
- Use Launchpad/Rosetta for translations once it supports TS files
// Intermediate // Intermediate
- Port on MacOS, Windows (and create an installer for Windows) - Progressing - Port on MacOS, Windows (and create an installer for Windows) - Progressing slowly
- Add some transparency (menus,...) - Add some transparency (menus,...)
// Harder // Harder
@ -50,6 +51,10 @@
- Clean up delayed progress column sorting code - Clean up delayed progress column sorting code
- Clean up pause after checking code - Clean up pause after checking code
- Test rss now that it has been rewritten - Test rss now that it has been rewritten
- check that negative ratio (overflow) is fixed
- Paused ratio=0??
- b0b14 didn't pause before fastresume (pause toggle problem)
- Update italian translator
- Wait for some bug fixes in libtorrent : - Wait for some bug fixes in libtorrent :
- upload/download limit per torrent (Ticket #83) - upload/download limit per torrent (Ticket #83)
- double free or corruption on exit (Ticket #84) FIXED? - double free or corruption on exit (Ticket #84) FIXED?
@ -69,6 +74,7 @@ LANGUAGES UPDATED:
beta4->beta5 changelog: beta4->beta5 changelog:
- BUGFIX: Wait for torrent_paused_alert before saving fast resume data - BUGFIX: Wait for torrent_paused_alert before saving fast resume data
- BUFFIG: Fixed overflow causing ratio data to be negative
- BUGFIX: Fixed progress column delayed sorting (after torrent finished checking) - BUGFIX: Fixed progress column delayed sorting (after torrent finished checking)
- BUGFIX: Finished torrents were still displayed as checking when paused by libtorrent on full disk (hit an assert) - BUGFIX: Finished torrents were still displayed as checking when paused by libtorrent on full disk (hit an assert)
- I18N: Updated Italian translation - I18N: Updated Italian translation

22
src/bittorrent.cpp

@ -251,6 +251,8 @@ bool bittorrent::resumeTorrent(QString hash){
index = pausedTorrents.indexOf(hash); index = pausedTorrents.indexOf(hash);
if(index != -1) if(index != -1)
pausedTorrents.removeAt(index); pausedTorrents.removeAt(index);
else
qDebug("Resumed Torrent was not in paused list");
return success; return success;
} }
@ -619,8 +621,9 @@ void bittorrent::loadDownloadUploadForTorrent(QString hash){
return; return;
} }
QPair<size_type,size_type> downUp; QPair<size_type,size_type> downUp;
downUp.first = (size_type)data_list.at(0).toLong(); downUp.first = (size_type)data_list.at(0).toLongLong();
downUp.second = (size_type)data_list.at(1).toLong(); downUp.second = (size_type)data_list.at(1).toLongLong();
Q_ASSERT(downUp.first >= 0 && downUp.second >= 0);
ratioData[hash] = downUp; ratioData[hash] = downUp;
} }
@ -642,10 +645,11 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash){
torrent_status torrentStatus = h.status(); torrent_status torrentStatus = h.status();
QString fileHash = QString(misc::toString(h.info_hash()).c_str()); QString fileHash = QString(misc::toString(h.info_hash()).c_str());
QPair<size_type,size_type> ratioInfo = ratioData.value(fileHash, QPair<size_type, size_type>(0,0)); QPair<size_type,size_type> ratioInfo = ratioData.value(fileHash, QPair<size_type, size_type>(0,0));
long download = torrentStatus.total_payload_download; size_type download = torrentStatus.total_payload_download;
download += ratioInfo.first; download += ratioInfo.first;
long upload = torrentStatus.total_payload_upload; size_type upload = torrentStatus.total_payload_upload;
upload += ratioInfo.second; upload += ratioInfo.second;
Q_ASSERT(download >= 0 && upload >= 0);
QFile ratio_file(torrentBackup.path()+QDir::separator()+ fileHash + ".ratio"); QFile ratio_file(torrentBackup.path()+QDir::separator()+ fileHash + ".ratio");
if(!ratio_file.open(QIODevice::WriteOnly | QIODevice::Text)){ if(!ratio_file.open(QIODevice::WriteOnly | QIODevice::Text)){
std::cerr << "Couldn't save ratio data for torrent: " << fileHash.toStdString() << '\n'; std::cerr << "Couldn't save ratio data for torrent: " << fileHash.toStdString() << '\n';
@ -931,7 +935,12 @@ void bittorrent::readAlerts(){
QString hash = QString(misc::toString(p->handle.info_hash()).c_str()); QString hash = QString(misc::toString(p->handle.info_hash()).c_str());
qDebug("Received torrent_paused_alert for %s", (const char*)hash.toUtf8()); qDebug("Received torrent_paused_alert for %s", (const char*)hash.toUtf8());
Q_ASSERT(!pausedTorrents.contains(hash)); Q_ASSERT(!pausedTorrents.contains(hash));
pausedTorrents << hash; torrent_handle h = p->handle;
if(h.is_valid() && h.is_paused()){
pausedTorrents << hash;
}else{
qDebug("Not adding torrent no pausedList, it is invalid or resumed");
}
} }
else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())){ else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())){
emit peerBlocked(QString(p->ip.to_string().c_str())); emit peerBlocked(QString(p->ip.to_string().c_str()));
@ -1036,7 +1045,8 @@ float bittorrent::getRealRatio(QString hash) const{
return 1.; return 1.;
return 10.; return 10.;
} }
float ratio = (float)upload / (float)download; float ratio = (double)upload / (double)download;
Q_ASSERT(ratio >= 0.);
if(ratio > 10.) if(ratio > 10.)
ratio = 10.; ratio = 10.;
return ratio; return ratio;

2
src/properties_imp.cpp

@ -93,7 +93,7 @@ properties::properties(QWidget *parent, bittorrent *BTSession, torrent_handle &h
else else
ratio = 10.; // Max ratio ratio = 10.; // Max ratio
}else{ }else{
ratio = (float)torrentStatus.total_payload_upload/(float)torrentStatus.total_payload_download; ratio = (double)torrentStatus.total_payload_upload/(double)torrentStatus.total_payload_download;
if(ratio > 10.){ if(ratio > 10.){
ratio = 10.; ratio = 10.;
} }

Loading…
Cancel
Save