Browse Source

Decrease probability of missing important alerts

During startup we can get above 1000 alerts at each pop even with only
30 torrents in the queue. This is because libtorrent will post
piece_finished_alert and file_completed_alert for each torrent. These
alerts push out of the way the ones we care about.
The alert queue will be grown to max only if needed. So we don't use
more memory. It will greatly depend on how many torrents a user has in
their session.

When getting fastresume_rejected_alert we need to act as fast as
possible in pausing it, otherwise there's a chance it will begin
downloading and writing to disk before we pause it.
adaptive-webui-19844
sledgehammer999 7 years ago
parent
commit
9ce619eac8
No known key found for this signature in database
GPG Key ID: 6E4A2D025B7CC9A2
  1. 12
      src/base/bittorrent/session.cpp
  2. 8
      src/base/bittorrent/torrenthandle.cpp

12
src/base/bittorrent/session.cpp

@ -1354,11 +1354,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
settingsPack.set_int(libt::settings_pack::active_tracker_limit, -1); settingsPack.set_int(libt::settings_pack::active_tracker_limit, -1);
settingsPack.set_int(libt::settings_pack::active_dht_limit, -1); settingsPack.set_int(libt::settings_pack::active_dht_limit, -1);
settingsPack.set_int(libt::settings_pack::active_lsd_limit, -1); settingsPack.set_int(libt::settings_pack::active_lsd_limit, -1);
// 1 active torrent force 2 connections. If you have more active torrents * 2 than connection limit, settingsPack.set_int(libt::settings_pack::alert_queue_size, std::numeric_limits<int>::max() / 2);
// connection limit will get extended. Multiply max connections or active torrents by 10 for queue.
// Ignore -1 values because we don't want to set a max int message queue
settingsPack.set_int(libt::settings_pack::alert_queue_size, std::max(1000,
10 * std::max(maxActiveTorrents() * 2, maxConnections())));
// Outgoing ports // Outgoing ports
settingsPack.set_int(libt::settings_pack::outgoing_port, outgoingPortsMin()); settingsPack.set_int(libt::settings_pack::outgoing_port, outgoingPortsMin());
@ -1633,11 +1629,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
sessionSettings.active_tracker_limit = -1; sessionSettings.active_tracker_limit = -1;
sessionSettings.active_dht_limit = -1; sessionSettings.active_dht_limit = -1;
sessionSettings.active_lsd_limit = -1; sessionSettings.active_lsd_limit = -1;
// 1 active torrent force 2 connections. If you have more active torrents * 2 than connection limit, sessionSettings.alert_queue_size = std::numeric_limits<int>::max() / 2;
// connection limit will get extended. Multiply max connections or active torrents by 10 for queue.
// Ignore -1 values because we don't want to set a max int message queue
sessionSettings.alert_queue_size = std::max(1000,
10 * std::max(maxActiveTorrents() * 2, maxConnections()));
// Outgoing ports // Outgoing ports
sessionSettings.outgoing_ports = std::make_pair(outgoingPortsMin(), outgoingPortsMax()); sessionSettings.outgoing_ports = std::make_pair(outgoingPortsMin(), outgoingPortsMax());

8
src/base/bittorrent/torrenthandle.cpp

@ -1661,15 +1661,11 @@ void TorrentHandle::handleSaveResumeDataFailedAlert(const libtorrent::save_resum
void TorrentHandle::handleFastResumeRejectedAlert(const libtorrent::fastresume_rejected_alert *p) void TorrentHandle::handleFastResumeRejectedAlert(const libtorrent::fastresume_rejected_alert *p)
{ {
qDebug("/!\\ Fast resume failed for %s, reason: %s", qUtf8Printable(name()), p->message().c_str());
updateStatus();
if (p->error.value() == libt::errors::mismatching_file_size) { if (p->error.value() == libt::errors::mismatching_file_size) {
// Mismatching file size (files were probably moved) // Mismatching file size (files were probably moved)
LogMsg(tr("File sizes mismatch for torrent '%1', pausing it.").arg(name()), Log::CRITICAL); pause();
m_hasMissingFiles = true; m_hasMissingFiles = true;
if (!isPaused()) LogMsg(tr("File sizes mismatch for torrent '%1', pausing it.").arg(name()), Log::CRITICAL);
pause();
} }
else { else {
LogMsg(tr("Fast resume data was rejected for torrent '%1'. Reason: %2. Checking again...") LogMsg(tr("Fast resume data was rejected for torrent '%1'. Reason: %2. Checking again...")

Loading…
Cancel
Save