From 5e1e983928f0ab331386c426c9f204bdce88b6f0 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 13 Sep 2019 12:31:26 +0800 Subject: [PATCH] Handle "alerts dropped" alert from libtorrent --- src/base/bittorrent/session.cpp | 13 +++++++++++++ src/base/bittorrent/session.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 09e9b950e..0092509e3 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -3902,6 +3902,11 @@ void Session::handleAlert(const lt::alert *a) case lt::external_ip_alert::alert_type: handleExternalIPAlert(static_cast(a)); break; +#if (LIBTORRENT_VERSION_NUM >= 10200) + case lt::alerts_dropped_alert::alert_type: + handleAlertsDroppedAlert(static_cast(a)); + break; +#endif } } catch (const std::exception &exc) { @@ -4365,6 +4370,14 @@ void Session::handleSessionStatsAlert(const lt::session_stats_alert *p) emit statsUpdated(); } +#if (LIBTORRENT_VERSION_NUM >= 10200) +void Session::handleAlertsDroppedAlert(const lt::alerts_dropped_alert *p) const +{ + LogMsg(tr("Error: Internal alert queue full and alerts were dropped, you might see degraded performance. Dropped alert types: %1. Message: %2") + .arg(QString::fromStdString(p->dropped_alerts.to_string()), QString::fromStdString(p->message())), Log::CRITICAL); +} +#endif + void Session::handleStateUpdateAlert(const lt::state_update_alert *p) { QVector updatedTorrents; diff --git a/src/base/bittorrent/session.h b/src/base/bittorrent/session.h index 65959f6bb..f6a03e508 100644 --- a/src/base/bittorrent/session.h +++ b/src/base/bittorrent/session.h @@ -562,6 +562,9 @@ namespace BitTorrent void handleListenFailedAlert(const lt::listen_failed_alert *p); void handleExternalIPAlert(const lt::external_ip_alert *p); void handleSessionStatsAlert(const lt::session_stats_alert *p); +#if (LIBTORRENT_VERSION_NUM >= 10200) + void handleAlertsDroppedAlert(const lt::alerts_dropped_alert *p) const; +#endif void createTorrentHandle(const lt::torrent_handle &nativeHandle);