From 69ef67d71ee06ef6125c1e72e0e348f588b8ead9 Mon Sep 17 00:00:00 2001
From: Arvid Norberg
seed is true if this peer is a seed.
upload_limit is the number of bytes per second we are allowed to send to this -peer every second. It may be -1 if there's no limit. The upload limits of all peers -should sum up to the upload limit set by session::set_upload_limit.
+peer every second. It may be -1 if there's no local limit on the peer. The global +limit and the torrent limit is always enforced anyway.download_limit is the number of bytes per second this peer is allowed to receive. -1 means it's unlimited.
load_balancing is a measurement of the balancing of free download (that we get) @@ -2390,7 +2390,7 @@ public: enum severity_t { debug, info, warning, critical, fatal, none }; - alert(severity_t severity, const std::string& msg); + alert(severity_t severity, std::string const& msg); virtual ~alert(); std::string const& msg() const; @@ -2402,6 +2402,16 @@ public:
This means that all alerts have at least a string describing it. They also have a severity level that can be used to sort them or present them to the user in different ways.
+There's another alert base class that all most alerts derives from, all the +alerts that are generated for a specific torrent are derived from:
++struct torrent_alert: alert +{ + torrent_alert(torrent_handle const& h, severity_t s, std::string const& msg); + + torrent_handle handle; +}; +
The specific alerts, that all derives from alert, are:
If the storage fails to read or write files that it needs access to, this alert is generated and the torrent is paused. It is generated as severity level fatal.
-struct file_error_alert: alert +struct file_error_alert: torrent_alert { file_error_alert( const torrent_handle& h , const std::stringHTTP/1.1 200 OK Content-Type: text/plain; charset=utf-8 Connection: close Transfer-Encoding: chunked Cache-Control: max-age=0, private, must-revalidate, no-transform Set-Cookie: i_like_gitea=daa41e07c86383aa; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=hEMYmH1ND9ncSaYxiATo7Iq3u8U6MTc1MzI0NDYwNTE5NTc4NDM3OQ; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax X-Frame-Options: SAMEORIGIN Date: Wed, 23 Jul 2025 04:23:25 GMT X-Cache-Status: HIT X-Cache-Age: 0 8000 From 69ef67d71ee06ef6125c1e72e0e348f588b8ead9 Mon Sep 17 00:00:00 2001 From: Arvid NorbergDate: Tue, 16 Jan 2007 05:05:52 +0000 Subject: [PATCH] made a common base class for torrent alerts. Made the bandwidth quota block size variable depending on the limit --- docs/manual.html | 92 ++++++++----------- docs/manual.rst | 95 ++++++++------------ examples/client_test.cpp | 10 +-- include/libtorrent/alert_types.hpp | 109 ++++++++--------------- include/libtorrent/bandwidth_manager.hpp | 6 ++ src/bandwidth_manager.cpp | 16 ++-- src/torrent.cpp | 16 ++-- src/torrent_handle.cpp | 36 -------- 8 files changed, 138 insertions(+), 242 deletions(-) diff --git a/docs/manual.html b/docs/manual.html index 4ca39318d..379a64038 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -1921,8 +1921,8 @@ in the torrent. Each boolean tells you if the peer has that piece (if it's set t or if the peer miss that piece (set to false). seed is true if this peer is a seed.
upload_limit is the number of bytes per second we are allowed to send to this -peer every second. It may be -1 if there's no limit. The upload limits of all peers -should sum up to the upload limit set by session::set_upload_limit.
+peer every second. It may be -1 if there's no local limit on the peer. The global +limit and the torrent limit is always enforced anyway.download_limit is the number of bytes per second this peer is allowed to receive. -1 means it's unlimited.
load_balancing is a measurement of the balancing of free download (that we get) @@ -2390,7 +2390,7 @@ public: enum severity_t { debug, info, warning, critical, fatal, none }; - alert(severity_t severity, const std::string& msg); + alert(severity_t severity, std::string const& msg); virtual ~alert(); std::string const& msg() const; @@ -2402,6 +2402,16 @@ public:
This means that all alerts have at least a string describing it. They also have a severity level that can be used to sort them or present them to the user in different ways.
+There's another alert base class that all most alerts derives from, all the +alerts that are generated for a specific torrent are derived from:
++struct torrent_alert: alert +{ + torrent_alert(torrent_handle const& h, severity_t s, std::string const& msg); + + torrent_handle handle; +}; +The specific alerts, that all derives from alert, are:
listen_failed_alert
@@ -2421,14 +2431,13 @@ struct listen_failed_alert: alertIf the storage fails to read or write files that it needs access to, this alert is generated and the torrent is paused. It is generated as severity level fatal.
-struct file_error_alert: alert +struct file_error_alert: torrent_alert { file_error_alert( const torrent_handle& h , const std::string 7fc request_bandwidth(p); else if (channel == peer_connection::download_channel) m_ses.m_dl_bandwidth_manager.request_bandwidth(p); - m_bandwidth_limit[channel].assign(17000); + m_bandwidth_limit[channel].assign(max_bandwidth_block_size); } } void torrent::assign_bandwidth(int channel, int amount) { assert(amount >= 0); - if (amount < 17000) expire_bandwidth(channel, 17000 - amount); + if (amount < max_bandwidth_block_size) + expire_bandwidth(channel, max_bandwidth_block_size - amount); } // called when torrent is finished (all interested pieces downloaded) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index 92f62e61c..96eb54d91 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -659,43 +659,7 @@ namespace libtorrent peer->get_peer_info(p); } } -/* - bool torrent_handle::send_chat_message(tcp::endpoint ip, std::string message) const - { - if (m_ses == 0) throw_invalid_handle(); - session_impl::mutex_t::scoped_lock l(m_ses->m_mutex); - boost::shared_ptrt = m_ses->find_torrent(m_info_hash).lock(); - if (!t) return false; - - for (torrent::const_peer_iterator i = t->begin(); - i != t->end(); ++i) - { - peer_connection* peer = i->second; - - // peers that haven't finished the handshake should - // not be included in this list - if (peer->associated_torrent().expired()) continue; - - tcp::endpoint sender = peer->get_socket()->remote_endpoint(); - // loop until we find the required ip tcp::endpoint - if (ip != sender) continue; - - bt_peer_connection* p = dynamic_cast (peer); - if (!p) return false; - - // peers that don's support chat message extension - // should not be included either - if (!p->supports_extension(extended_chat_message)) - return false; - - // send the message - p->write_chat_message(message); - return true; - } - return false; - } -*/ void torrent_handle::get_download_queue(std::vector & queue) const { INVARIANT_CHECK; 0