Browse Source

- Added some more torrent_handle checking to be sure we don't use invalid ones

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
8f7de730cc
  1. 13
      src/bittorrent.cpp

13
src/bittorrent.cpp

@ -998,13 +998,16 @@ void bittorrent::readAlerts() { @@ -998,13 +998,16 @@ void bittorrent::readAlerts() {
while (a.get()) {
if (torrent_finished_alert* p = dynamic_cast<torrent_finished_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if(h.is_valid()){
QString hash = h.hash();
qDebug("Received finished alert for %s", h.name().toUtf8().data());
setFinishedTorrent(hash);
emit finishedTorrent(h);
}
}
else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if(h.is_valid())
emit fullDiskError(h);
}
else if (dynamic_cast<listen_failed_alert*>(a.get())) {
@ -1014,6 +1017,7 @@ void bittorrent::readAlerts() { @@ -1014,6 +1017,7 @@ void bittorrent::readAlerts() {
else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())) {
// Level: fatal
QTorrentHandle h(p->handle);
if(h.is_valid()){
QString hash = h.hash();
QList<QPair<QString, QString> > errors = trackersErrors.value(hash, QList<QPair<QString, QString> >());
if(errors.size() > 5)
@ -1025,8 +1029,10 @@ void bittorrent::readAlerts() { @@ -1025,8 +1029,10 @@ void bittorrent::readAlerts() {
emit trackerAuthenticationRequired(h);
}
}
}
else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if(h.is_valid()){
QString hash = h.hash();
qDebug("Received torrent_paused_alert for %s", hash.toUtf8().data());
if(!pausedTorrents.contains(hash)) {
@ -1042,19 +1048,23 @@ void bittorrent::readAlerts() { @@ -1042,19 +1048,23 @@ void bittorrent::readAlerts() {
qDebug("Received alert for already paused torrent");
}
}
}
else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) {
emit peerBlocked(QString::fromUtf8(p->ip.to_string().c_str()));
}
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if(h.is_valid()){
qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toUtf8().data(), p->msg().c_str());
emit fastResumeDataRejected(QString::fromUtf8(p->handle.name().c_str()));
emit fastResumeDataRejected(h.name());
}
}
else if (url_seed_alert* p = dynamic_cast<url_seed_alert*>(a.get())) {
emit urlSeedProblem(QString::fromUtf8(p->url.c_str()), QString::fromUtf8(p->msg().c_str()));
}
else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if(h.is_valid()){
QString hash = h.hash();
qDebug("%s have just finished checking", hash.toUtf8().data());
int index = torrentsToPauseAfterChecking.indexOf(hash);
@ -1065,6 +1075,7 @@ void bittorrent::readAlerts() { @@ -1065,6 +1075,7 @@ void bittorrent::readAlerts() {
}
emit torrentFinishedChecking(hash);
}
}
a = s->pop_alert();
}
}

Loading…
Cancel
Save