| bandwidth_limit.hpp | | bandwidth_limit.hpp | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| POSSIBILITY OF SUCH DAMAGE. | | POSSIBILITY OF SUCH DAMAGE. | |
| | | | |
| */ | | */ | |
| | | | |
| #ifndef TORRENT_BANDWIDTH_CHANNEL_HPP_INCLUDED | | #ifndef TORRENT_BANDWIDTH_CHANNEL_HPP_INCLUDED | |
| #define TORRENT_BANDWIDTH_CHANNEL_HPP_INCLUDED | | #define TORRENT_BANDWIDTH_CHANNEL_HPP_INCLUDED | |
| | | | |
| #include <boost/integer_traits.hpp> | | #include <boost/integer_traits.hpp> | |
|
| | | #include <boost/cstdint.hpp> | |
| | | | |
| #include "libtorrent/assert.hpp" | | #include "libtorrent/assert.hpp" | |
| | | | |
| namespace libtorrent { | | namespace libtorrent { | |
| | | | |
| // member of peer_connection | | // member of peer_connection | |
| struct TORRENT_EXPORT bandwidth_channel | | struct TORRENT_EXPORT bandwidth_channel | |
| { | | { | |
| static const int inf = boost::integer_traits<int>::const_max; | | static const int inf = boost::integer_traits<int>::const_max; | |
| | | | |
| | | | |
| skipping to change at line 69 | | skipping to change at line 70 | |
| } | | } | |
| | | | |
| int throttle() const | | int throttle() const | |
| { | | { | |
| return m_limit; | | return m_limit; | |
| } | | } | |
| | | | |
| int quota_left() const | | int quota_left() const | |
| { | | { | |
| if (m_limit == 0) return inf; | | if (m_limit == 0) return inf; | |
|
| return (std::max)(m_quota_left, 0); | | return (std::max)(m_quota_left, boost::int64_t(0)); | |
| } | | } | |
| | | | |
| void update_quota(int dt_milliseconds) | | void update_quota(int dt_milliseconds) | |
| { | | { | |
| if (m_limit == 0) return; | | if (m_limit == 0) return; | |
| m_quota_left += (m_limit * dt_milliseconds + 500) / 1000; | | m_quota_left += (m_limit * dt_milliseconds + 500) / 1000; | |
| if (m_quota_left > m_limit * 3) m_quota_left = m_limit * 3; | | if (m_quota_left > m_limit * 3) m_quota_left = m_limit * 3; | |
|
| distribute_quota = (std::max)(m_quota_left, 0); | | distribute_quota = (std::max)(m_quota_left, boost::int64_t(0 | |
| // fprintf(stderr, "%p: [%d]: + %d limit: %d\n", this, dt_milli | | )); | |
| seconds, (m_limit * dt_milliseconds + 500) / 1000, m_limit); | | // fprintf(stderr, "%p: [%d]: + %"PRId64" limit: %"PRId64" quot | |
| | | a_left: %"PRId64"\n", this | |
| | | // , dt_milliseconds, (m_limit * dt_milliseconds + 500) | |
| | | / 1000, m_limit | |
| | | // , m_quota_left); | |
| } | | } | |
| | | | |
| // this is used when connections disconnect with | | // this is used when connections disconnect with | |
| // some quota left. It's returned to its bandwidth | | // some quota left. It's returned to its bandwidth | |
| // channels. | | // channels. | |
| void return_quota(int amount) | | void return_quota(int amount) | |
| { | | { | |
| TORRENT_ASSERT(amount >= 0); | | TORRENT_ASSERT(amount >= 0); | |
| if (m_limit == 0) return; | | if (m_limit == 0) return; | |
| TORRENT_ASSERT(m_quota_left <= m_quota_left + amount); | | TORRENT_ASSERT(m_quota_left <= m_quota_left + amount); | |
| m_quota_left += amount; | | m_quota_left += amount; | |
| } | | } | |
| | | | |
| void use_quota(int amount) | | void use_quota(int amount) | |
| { | | { | |
| TORRENT_ASSERT(amount >= 0); | | TORRENT_ASSERT(amount >= 0); | |
| TORRENT_ASSERT(m_limit >= 0); | | TORRENT_ASSERT(m_limit >= 0); | |
| if (m_limit == 0) return; | | if (m_limit == 0) return; | |
|
| | | | |
| | | // fprintf(stderr, "%p: - %"PRId64" limit: %"PRId64" quota_left | |
| | | : %"PRId64"\n", this | |
| | | // , amount, m_limit, m_quota_left); | |
| m_quota_left -= amount; | | m_quota_left -= amount; | |
| } | | } | |
| | | | |
| // used as temporary storage while distributing | | // used as temporary storage while distributing | |
| // bandwidth | | // bandwidth | |
| int tmp; | | int tmp; | |
| | | | |
| // this is the number of bytes to distribute this round | | // this is the number of bytes to distribute this round | |
| int distribute_quota; | | int distribute_quota; | |
| | | | |
| private: | | private: | |
| | | | |
| // this is the amount of bandwidth we have | | // this is the amount of bandwidth we have | |
| // been assigned without using yet. | | // been assigned without using yet. | |
|
| int m_quota_left; | | boost::int64_t m_quota_left; | |
| | | | |
| // the limit is the number of bytes | | // the limit is the number of bytes | |
| // per second we are allowed to use. | | // per second we are allowed to use. | |
|
| int m_limit; | | boost::int64_t m_limit; | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 6 change blocks. |
| 6 lines changed or deleted | | 15 lines changed or added | |
|
| peer_connection.hpp | | peer_connection.hpp | |
| | | | |
| skipping to change at line 539 | | skipping to change at line 539 | |
| // upload and download channel state | | // upload and download channel state | |
| // enum from peer_info::bw_state | | // enum from peer_info::bw_state | |
| char m_channel_state[2]; | | char m_channel_state[2]; | |
| | | | |
| size_type uploaded_since_unchoke() const | | size_type uploaded_since_unchoke() const | |
| { return m_statistics.total_payload_upload() - m_uploaded_at
_last_unchoke; } | | { return m_statistics.total_payload_upload() - m_uploaded_at
_last_unchoke; } | |
| | | | |
| size_type downloaded_since_unchoke() const | | size_type downloaded_since_unchoke() const | |
| { return m_statistics.total_payload_download() - m_downloade
d_at_last_unchoke; } | | { return m_statistics.total_payload_download() - m_downloade
d_at_last_unchoke; } | |
| | | | |
|
| void setup_receive(); | | enum sync_t { read_async, read_sync }; | |
| | | void setup_receive(sync_t sync = read_sync); | |
| | | | |
| protected: | | protected: | |
| | | | |
|
| enum sync_t { read_async, read_sync }; | | | |
| size_t try_read(sync_t s, error_code& ec); | | size_t try_read(sync_t s, error_code& ec); | |
| | | | |
| virtual void get_specific_peer_info(peer_info& p) const = 0; | | virtual void get_specific_peer_info(peer_info& p) const = 0; | |
| | | | |
| virtual void write_choke() = 0; | | virtual void write_choke() = 0; | |
| virtual void write_unchoke() = 0; | | virtual void write_unchoke() = 0; | |
| virtual void write_interested() = 0; | | virtual void write_interested() = 0; | |
| virtual void write_not_interested() = 0; | | virtual void write_not_interested() = 0; | |
| virtual void write_request(peer_request const& r) = 0; | | virtual void write_request(peer_request const& r) = 0; | |
| virtual void write_cancel(peer_request const& r) = 0; | | virtual void write_cancel(peer_request const& r) = 0; | |
| | | | |
| skipping to change at line 932 | | skipping to change at line 932 | |
| boost::uint8_t m_desired_queue_size; | | boost::uint8_t m_desired_queue_size; | |
| | | | |
| // the number of piece requests we have rejected | | // the number of piece requests we have rejected | |
| // in a row because the peer is choked. This is | | // in a row because the peer is choked. This is | |
| // used to re-send the choked message in case the | | // used to re-send the choked message in case the | |
| // other end keeps requesting pieces while being | | // other end keeps requesting pieces while being | |
| // choked, and eventuelly disconnect if it keeps | | // choked, and eventuelly disconnect if it keeps | |
| // requesting too many pieces while being choked | | // requesting too many pieces while being choked | |
| boost::uint8_t m_choke_rejects; | | boost::uint8_t m_choke_rejects; | |
| | | | |
|
| | | // counts the number of recursive calls to on_receive_data | |
| | | // used to limit recursion | |
| | | boost::uint8_t m_read_recurse:5; | |
| | | | |
| // if this is true, the disconnection | | // if this is true, the disconnection | |
| // timestamp is not updated when the connection | | // timestamp is not updated when the connection | |
| // is closed. This means the time until we can | | // is closed. This means the time until we can | |
| // reconnect to this peer is shorter, and likely | | // reconnect to this peer is shorter, and likely | |
| // immediate. | | // immediate. | |
| bool m_fast_reconnect:1; | | bool m_fast_reconnect:1; | |
| | | | |
| // is true if it was we that connected to the peer | | // is true if it was we that connected to the peer | |
| // and false if we got an incoming connection | | // and false if we got an incoming connection | |
| // could be considered: true = local, false = remote | | // could be considered: true = local, false = remote | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 6 lines changed or added | |
|
| version.hpp | | version.hpp | |
| | | | |
| skipping to change at line 38 | | skipping to change at line 38 | |
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| POSSIBILITY OF SUCH DAMAGE. | | POSSIBILITY OF SUCH DAMAGE. | |
| | | | |
| */ | | */ | |
| | | | |
| #ifndef TORRENT_VERSION_HPP_INCLUDED | | #ifndef TORRENT_VERSION_HPP_INCLUDED | |
| #define TORRENT_VERSION_HPP_INCLUDED | | #define TORRENT_VERSION_HPP_INCLUDED | |
| | | | |
| #define LIBTORRENT_VERSION_MAJOR 0 | | #define LIBTORRENT_VERSION_MAJOR 0 | |
| #define LIBTORRENT_VERSION_MINOR 15 | | #define LIBTORRENT_VERSION_MINOR 15 | |
|
| #define LIBTORRENT_VERSION_TINY 2 | | #define LIBTORRENT_VERSION_TINY 3 | |
| | | | |
|
| #define LIBTORRENT_VERSION "0.15.2.0" | | #define LIBTORRENT_VERSION "0.15.3.0" | |
| #define LIBTORRENT_REVISION "$Rev: 4758 $" | | #define LIBTORRENT_REVISION "$Rev: 4826 $" | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 2 change blocks. |
| 3 lines changed or deleted | | 3 lines changed or added | |
|