From 8d9e73cf76c9cbebcc42d0bc40c6bebd0728386c Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 20 Feb 2004 15:22:23 +0000 Subject: [PATCH] *** empty log message *** --- docs/manual.html | 15 +++++++-------- docs/manual.rst | 15 +++++++-------- src/peer_connection.cpp | 9 +++++++++ 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/docs/manual.html b/docs/manual.html index cc3876f38..fde80cdec 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -438,8 +438,8 @@ public: torrent_info(const entry& torrent_file) - typedef std::vector>file>::const_iterator file_iterator; - typedef std::vector<file>::const_reverse_iterator reverse_file_iterator; + typedef std::vector>file_entry>::const_iterator file_iterator; + typedef std::vector<file_entry>::const_reverse_iterator reverse_file_iterator; file_iterator begin_files() const; file_iterator end_files() const; @@ -447,14 +447,14 @@ public: reverse_file_iterator rend_files() const; int num_files() const; - const file& file_at(int index) const; + const file_entry& file_at(int index) const; const std::vector<announce_entry>& trackers() const; int prioritize_tracker(int index); - entry::integer_type total_size() const; - entry::integer_type piece_length() const; + size_type total_size() const; + size_type piece_length() const; int num_pieces() const; const sha1_hash& info_hash() const; const std::stirng& name() const; @@ -464,7 +464,7 @@ public: void print(std::ostream& os) const; - entry::integer_type piece_size(unsigned int index) const; + size_type piece_size(unsigned int index) const; const sha1_hash& hash_for_piece(unsigned int index) const; }; @@ -477,7 +477,7 @@ struct file_entry { std::string path; std::string filename; - entry::integer_type size; + size_type size; };

If you need index-access to files you can use the num_files() and file_at() @@ -588,7 +588,6 @@ struct torrent_status { enum state_t { - invalid_handle, queued_for_checking, checking_files, connecting_to_tracker, diff --git a/docs/manual.rst b/docs/manual.rst index b1d98a703..baa6f29a8 100755 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -406,8 +406,8 @@ The ``torrent_info`` has the following synopsis:: torrent_info(const entry& torrent_file) - typedef std::vector>file>::const_iterator file_iterator; - typedef std::vector::const_reverse_iterator reverse_file_iterator; + typedef std::vector>file_entry>::const_iterator file_iterator; + typedef std::vector::const_reverse_iterator reverse_file_iterator; file_iterator begin_files() const; file_iterator end_files() const; @@ -415,14 +415,14 @@ The ``torrent_info`` has the following synopsis:: reverse_file_iterator rend_files() const; int num_files() const; - const file& file_at(int index) const; + const file_entry& file_at(int index) const; const std::vector& trackers() const; int prioritize_tracker(int index); - entry::integer_type total_size() const; - entry::integer_type piece_length() const; + size_type total_size() const; + size_type piece_length() const; int num_pieces() const; const sha1_hash& info_hash() const; const std::stirng& name() const; @@ -432,7 +432,7 @@ The ``torrent_info`` has the following synopsis:: void print(std::ostream& os) const; - entry::integer_type piece_size(unsigned int index) const; + size_type piece_size(unsigned int index) const; const sha1_hash& hash_for_piece(unsigned int index) const; }; @@ -447,7 +447,7 @@ iterators with the type ``file_entry``. { std::string path; std::string filename; - entry::integer_type size; + size_type size; }; If you need index-access to files you can use the ``num_files()`` and ``file_at()`` @@ -586,7 +586,6 @@ It contains the following fields:: { enum state_t { - invalid_handle, queued_for_checking, checking_files, connecting_to_tracker, diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 7bbd2e0a6..1ea040e01 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -564,6 +564,15 @@ namespace libtorrent r.start = detail::read_int32(ptr); r.length = detail::read_int32(ptr); + if (m_requests.size() > 40) + { + // don't allow clients to abuse our + // memory consumption. + // ignore requests if the client + // is making too many of them. + return; + } + // make sure this request // is legal and taht the peer // is not choked