| assert.hpp | | assert.hpp | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 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_ASSERT | | #ifndef TORRENT_ASSERT | |
| | | | |
| #include "libtorrent/config.hpp" | | #include "libtorrent/config.hpp" | |
|
| | | | |
| | | #if !defined TORRENT_DEBUG | |
| | | #define TORRENT_ASSERT(a) do {} while(false) | |
| | | #else | |
| | | | |
| #include <string> | | #include <string> | |
| | | | |
| #ifdef __GNUC__ | | #ifdef __GNUC__ | |
| std::string demangle(char const* name); | | std::string demangle(char const* name); | |
| #endif | | #endif | |
| | | | |
|
| #if (defined __linux__ || defined __MACH__) && defined __GNUC__ && !defined
(NDEBUG) | | #if (defined __linux__ || defined __MACH__) && defined __GNUC__ && defined
TORRENT_DEBUG | |
| | | | |
| TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* fil
e, char const* function); | | TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* fil
e, char const* function); | |
| #define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __F
ILE__, __PRETTY_FUNCTION__); } while (false) | | #define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __F
ILE__, __PRETTY_FUNCTION__); } while (false) | |
| | | | |
| #else | | #else | |
| #include <cassert> | | #include <cassert> | |
| #define TORRENT_ASSERT(x) assert(x) | | #define TORRENT_ASSERT(x) assert(x) | |
| #endif | | #endif | |
| | | | |
| #endif | | #endif | |
|
| | | | |
| | | #endif | |
| | | | |
End of changes. 3 change blocks. |
| 1 lines changed or deleted | | 6 lines changed or added | |
|
| bandwidth_manager.hpp | | bandwidth_manager.hpp | |
| | | | |
| skipping to change at line 159 | | skipping to change at line 159 | |
| void close() | | void close() | |
| { | | { | |
| m_abort = true; | | m_abort = true; | |
| m_queue.clear(); | | m_queue.clear(); | |
| m_history.clear(); | | m_history.clear(); | |
| m_current_quota = 0; | | m_current_quota = 0; | |
| error_code ec; | | error_code ec; | |
| m_history_timer.cancel(ec); | | m_history_timer.cancel(ec); | |
| } | | } | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| bool is_queued(PeerConnection const* peer) const | | bool is_queued(PeerConnection const* peer) const | |
| { | | { | |
| mutex_t::scoped_lock l(m_mutex); | | mutex_t::scoped_lock l(m_mutex); | |
| return is_queued(peer); | | return is_queued(peer); | |
| } | | } | |
| | | | |
| bool is_queued(PeerConnection const* peer, boost::mutex::scoped_lock
& l) const | | bool is_queued(PeerConnection const* peer, boost::mutex::scoped_lock
& l) const | |
| { | | { | |
| for (typename queue_t::const_iterator i = m_queue.begin() | | for (typename queue_t::const_iterator i = m_queue.begin() | |
| , end(m_queue.end()); i != end; ++i) | | , end(m_queue.end()); i != end; ++i) | |
| | | | |
| skipping to change at line 225 | | skipping to change at line 225 | |
| typename queue_t::reverse_iterator i(m_queue.rbegin()); | | typename queue_t::reverse_iterator i(m_queue.rbegin()); | |
| while (i != m_queue.rend() && priority > i->priority) | | while (i != m_queue.rend() && priority > i->priority) | |
| { | | { | |
| ++i->priority; | | ++i->priority; | |
| ++i; | | ++i; | |
| } | | } | |
| m_queue.insert(i.base(), bw_queue_entry<PeerConnection, Torr
ent>(peer, blk, priority)); | | m_queue.insert(i.base(), bw_queue_entry<PeerConnection, Torr
ent>(peer, blk, priority)); | |
| if (!m_queue.empty()) hand_out_bandwidth(l); | | if (!m_queue.empty()) hand_out_bandwidth(l); | |
| } | | } | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| void check_invariant() const | | void check_invariant() const | |
| { | | { | |
| int current_quota = 0; | | int current_quota = 0; | |
| for (typename history_t::const_iterator i | | for (typename history_t::const_iterator i | |
| = m_history.begin(), end(m_history.end()); i != end;
++i) | | = m_history.begin(), end(m_history.end()); i != end;
++i) | |
| { | | { | |
| current_quota += i->amount; | | current_quota += i->amount; | |
| } | | } | |
| TORRENT_ASSERT(current_quota == m_current_quota); | | TORRENT_ASSERT(current_quota == m_current_quota); | |
| | | | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| bencode.hpp | | bencode.hpp | |
| | | | |
| skipping to change at line 234 | | skipping to change at line 234 | |
| { | | { | |
| if (depth >= 100) | | if (depth >= 100) | |
| { | | { | |
| err = true; | | err = true; | |
| return; | | return; | |
| } | | } | |
| | | | |
| if (in == end) | | if (in == end) | |
| { | | { | |
| err = true; | | err = true; | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
| switch (*in) | | switch (*in) | |
| { | | { | |
| | | | |
| // ---------------------------------------------- | | // ---------------------------------------------- | |
| // integer | | // integer | |
| case 'i': | | case 'i': | |
| { | | { | |
| ++in; // 'i' | | ++in; // 'i' | |
| std::string val = read_until(in, end, 'e', e
rr); | | std::string val = read_until(in, end, 'e', e
rr); | |
| if (err) return; | | if (err) return; | |
| TORRENT_ASSERT(*in == 'e'); | | TORRENT_ASSERT(*in == 'e'); | |
| ++in; // 'e' | | ++in; // 'e' | |
| ret = entry(entry::int_t); | | ret = entry(entry::int_t); | |
| ret.integer() = boost::lexical_cast<entry::i
nteger_type>(val); | | ret.integer() = boost::lexical_cast<entry::i
nteger_type>(val); | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| } break; | | } break; | |
| | | | |
| // ---------------------------------------------- | | // ---------------------------------------------- | |
| // list | | // list | |
| case 'l': | | case 'l': | |
| { | | { | |
| ret = entry(entry::list_t); | | ret = entry(entry::list_t); | |
| ++in; // 'l' | | ++in; // 'l' | |
| while (*in != 'e') | | while (*in != 'e') | |
| { | | { | |
| ret.list().push_back(entry()); | | ret.list().push_back(entry()); | |
| entry& e = ret.list().back(); | | entry& e = ret.list().back(); | |
| bdecode_recursive(in, end, e, err, d
epth + 1); | | bdecode_recursive(in, end, e, err, d
epth + 1); | |
| if (err) | | if (err) | |
| { | | { | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
| if (in == end) | | if (in == end) | |
| { | | { | |
| err = true; | | err = true; | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
| } | | } | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| TORRENT_ASSERT(*in == 'e'); | | TORRENT_ASSERT(*in == 'e'); | |
| ++in; // 'e' | | ++in; // 'e' | |
| } break; | | } break; | |
| | | | |
| // ---------------------------------------------- | | // ---------------------------------------------- | |
| // dictionary | | // dictionary | |
| case 'd': | | case 'd': | |
| { | | { | |
| ret = entry(entry::dictionary_t); | | ret = entry(entry::dictionary_t); | |
| ++in; // 'd' | | ++in; // 'd' | |
| while (*in != 'e') | | while (*in != 'e') | |
| { | | { | |
| entry key; | | entry key; | |
| bdecode_recursive(in, end, key, err,
depth + 1); | | bdecode_recursive(in, end, key, err,
depth + 1); | |
| if (err || key.type() != entry::stri
ng_t) | | if (err || key.type() != entry::stri
ng_t) | |
| { | | { | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
| entry& e = ret[key.string()]; | | entry& e = ret[key.string()]; | |
| bdecode_recursive(in, end, e, err, d
epth + 1); | | bdecode_recursive(in, end, e, err, d
epth + 1); | |
| if (err) | | if (err) | |
| { | | { | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
| if (in == end) | | if (in == end) | |
| { | | { | |
| err = true; | | err = true; | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
| } | | } | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| TORRENT_ASSERT(*in == 'e'); | | TORRENT_ASSERT(*in == 'e'); | |
| ++in; // 'e' | | ++in; // 'e' | |
| } break; | | } break; | |
| | | | |
| // ---------------------------------------------- | | // ---------------------------------------------- | |
| // string | | // string | |
| default: | | default: | |
| if (isdigit((unsigned char)*in)) | | if (isdigit((unsigned char)*in)) | |
| { | | { | |
| std::string len_s = read_until(in, e
nd, ':', err); | | std::string len_s = read_until(in, e
nd, ':', err); | |
| if (err) | | if (err) | |
| { | | { | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
| TORRENT_ASSERT(*in == ':'); | | TORRENT_ASSERT(*in == ':'); | |
| ++in; // ':' | | ++in; // ':' | |
| int len = std::atoi(len_s.c_str()); | | int len = std::atoi(len_s.c_str()); | |
| ret = entry(entry::string_t); | | ret = entry(entry::string_t); | |
| read_string(in, end, len, ret.string
(), err); | | read_string(in, end, len, ret.string
(), err); | |
| if (err) | | if (err) | |
| { | | { | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| err = true; | | err = true; | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| return; | | return; | |
| } | | } | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ret.m_type_queried = false; | | ret.m_type_queried = false; | |
| #endif | | #endif | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template<class OutIt> | | template<class OutIt> | |
| int bencode(OutIt out, const entry& e) | | int bencode(OutIt out, const entry& e) | |
| { | | { | |
| return detail::bencode_recursive(out, e); | | return detail::bencode_recursive(out, e); | |
| } | | } | |
| | | | |
| template<class InIt> | | template<class InIt> | |
| entry bdecode(InIt start, InIt end) | | entry bdecode(InIt start, InIt end) | |
| { | | { | |
| entry e; | | entry e; | |
| bool err = false; | | bool err = false; | |
| detail::bdecode_recursive(start, end, e, err, 0); | | detail::bdecode_recursive(start, end, e, err, 0); | |
|
| | | #ifdef TORRENT_DEBUG | |
| TORRENT_ASSERT(e.m_type_queried == false); | | TORRENT_ASSERT(e.m_type_queried == false); | |
|
| | | #endif | |
| if (err) return entry(); | | if (err) return entry(); | |
| return e; | | return e; | |
| } | | } | |
| | | | |
| template<class InIt> | | template<class InIt> | |
| entry bdecode(InIt start, InIt end, int& len) | | entry bdecode(InIt start, InIt end, int& len) | |
| { | | { | |
| entry e; | | entry e; | |
| bool err = false; | | bool err = false; | |
| InIt s = start; | | InIt s = start; | |
| | | | |
End of changes. 15 change blocks. |
| 13 lines changed or deleted | | 15 lines changed or added | |
|
| bt_peer_connection.hpp | | bt_peer_connection.hpp | |
| | | | |
| skipping to change at line 236 | | skipping to change at line 236 | |
| | | | |
| // FAST extension | | // FAST extension | |
| void write_have_all(); | | void write_have_all(); | |
| void write_have_none(); | | void write_have_none(); | |
| void write_reject_request(peer_request const&); | | void write_reject_request(peer_request const&); | |
| void write_allow_fast(int piece); | | void write_allow_fast(int piece); | |
| | | | |
| void on_connected(); | | void on_connected(); | |
| void on_metadata(); | | void on_metadata(); | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| void check_invariant() const; | | void check_invariant() const; | |
| ptime m_last_choke; | | ptime m_last_choke; | |
| #endif | | #endif | |
| | | | |
| private: | | private: | |
| | | | |
| bool dispatch_message(int received); | | bool dispatch_message(int received); | |
| // returns the block currently being | | // returns the block currently being | |
| // downloaded. And the progress of that | | // downloaded. And the progress of that | |
| // block. If the peer isn't downloading | | // block. If the peer isn't downloading | |
| | | | |
| skipping to change at line 410 | | skipping to change at line 410 | |
| // remote peer, this will hold RC4_decrypt(vc). Destroyed | | // remote peer, this will hold RC4_decrypt(vc). Destroyed | |
| // after the sync step. | | // after the sync step. | |
| boost::scoped_array<char> m_sync_vc; | | boost::scoped_array<char> m_sync_vc; | |
| | | | |
| // (incoming only) synchronize hash with remote peer, holds | | // (incoming only) synchronize hash with remote peer, holds | |
| // the sync hash (hash("req1",secret)). Destroyed after the | | // the sync hash (hash("req1",secret)). Destroyed after the | |
| // sync step. | | // sync step. | |
| boost::scoped_ptr<sha1_hash> m_sync_hash; | | boost::scoped_ptr<sha1_hash> m_sync_hash; | |
| #endif // #ifndef TORRENT_DISABLE_ENCRYPTION | | #endif // #ifndef TORRENT_DISABLE_ENCRYPTION | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| // this is set to true when the client's | | // this is set to true when the client's | |
| // bitfield is sent to this peer | | // bitfield is sent to this peer | |
| bool m_sent_bitfield; | | bool m_sent_bitfield; | |
| | | | |
| bool m_in_constructor; | | bool m_in_constructor; | |
| | | | |
| bool m_sent_handshake; | | bool m_sent_handshake; | |
| #endif | | #endif | |
| | | | |
| }; | | }; | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| create_torrent.hpp | | create_torrent.hpp | |
| | | | |
| skipping to change at line 158 | | skipping to change at line 158 | |
| #else | | #else | |
| std::string const& leaf = l.filename(); | | std::string const& leaf = l.filename(); | |
| #endif | | #endif | |
| if (leaf == ".." || leaf == ".") return; | | if (leaf == ".." || leaf == ".") return; | |
| if (!pred(l)) return; | | if (!pred(l)) return; | |
| path f(p / l); | | path f(p / l); | |
| if (is_directory(f)) | | if (is_directory(f)) | |
| { | | { | |
| for (directory_iterator i(f), end; i != end;
++i) | | for (directory_iterator i(f), end; i != end;
++i) | |
| #if BOOST_VERSION < 103600 | | #if BOOST_VERSION < 103600 | |
|
| add_files_impl(fs, p, l / i->leaf(),
pred); | | add_files_impl(fs, p, l / i->path().
leaf(), pred); | |
| #else | | #else | |
|
| add_files_impl(fs, p, l / i->filenam
e(), pred); | | add_files_impl(fs, p, l / i->path().
filename(), pred); | |
| #endif | | #endif | |
| } | | } | |
| else | | else | |
| { | | { | |
| fs.add_file(l, file_size(f)); | | fs.add_file(l, file_size(f)); | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| template <class Pred> | | template <class Pred> | |
| | | | |
| skipping to change at line 182 | | skipping to change at line 182 | |
| { | | { | |
| #if BOOST_VERSION < 103600 | | #if BOOST_VERSION < 103600 | |
| detail::add_files_impl(fs, complete(file).branch_path(), fil
e.leaf(), p); | | detail::add_files_impl(fs, complete(file).branch_path(), fil
e.leaf(), p); | |
| #else | | #else | |
| detail::add_files_impl(fs, complete(file).parent_path(), fil
e.filename(), p); | | detail::add_files_impl(fs, complete(file).parent_path(), fil
e.filename(), p); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| inline void add_files(file_storage& fs, boost::filesystem::path cons
t& file) | | inline void add_files(file_storage& fs, boost::filesystem::path cons
t& file) | |
| { | | { | |
|
| | | #if BOOST_VERSION < 103600 | |
| detail::add_files_impl(fs, complete(file).branch_path(), fil
e.leaf(), detail::default_pred); | | detail::add_files_impl(fs, complete(file).branch_path(), fil
e.leaf(), detail::default_pred); | |
|
| | | #else | |
| | | detail::add_files_impl(fs, complete(file).parent_path(), fil | |
| | | e.filename(), detail::default_pred); | |
| | | #endif | |
| } | | } | |
| | | | |
| template <class Fun> | | template <class Fun> | |
| void set_piece_hashes(create_torrent& t, boost::filesystem::path con
st& p, Fun f) | | void set_piece_hashes(create_torrent& t, boost::filesystem::path con
st& p, Fun f) | |
| { | | { | |
| file_pool fp; | | file_pool fp; | |
| boost::scoped_ptr<storage_interface> st( | | boost::scoped_ptr<storage_interface> st( | |
| default_storage_constructor(const_cast<file_storage&
>(t.files()), p, fp)); | | default_storage_constructor(const_cast<file_storage&
>(t.files()), p, fp)); | |
| | | | |
| // calculate the hash for all pieces | | // calculate the hash for all pieces | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 7 lines changed or added | |
|
| entry.hpp | | entry.hpp | |
| | | | |
| skipping to change at line 208 | | skipping to change at line 208 | |
| union | | union | |
| { | | { | |
| char data[detail::max4<sizeof(list_type) | | char data[detail::max4<sizeof(list_type) | |
| , sizeof(dictionary_type) | | , sizeof(dictionary_type) | |
| , sizeof(string_type) | | , sizeof(string_type) | |
| , sizeof(integer_type)>::value]; | | , sizeof(integer_type)>::value]; | |
| integer_type dummy_aligner; | | integer_type dummy_aligner; | |
| }; | | }; | |
| #endif | | #endif | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| public: | | public: | |
| // in debug mode this is set to false by bdecode | | // in debug mode this is set to false by bdecode | |
| // to indicate that the program has not yet queried | | // to indicate that the program has not yet queried | |
| // the type of this entry, and sould not assume | | // the type of this entry, and sould not assume | |
| // that it has a certain type. This is asserted in | | // that it has a certain type. This is asserted in | |
| // the accessor functions. This does not apply if | | // the accessor functions. This does not apply if | |
| // exceptions are used. | | // exceptions are used. | |
| mutable bool m_type_queried; | | mutable bool m_type_queried; | |
| #endif | | #endif | |
| }; | | }; | |
| | | | |
| inline std::ostream& operator<<(std::ostream& os, const entry& e) | | inline std::ostream& operator<<(std::ostream& os, const entry& e) | |
| { | | { | |
| e.print(os, 0); | | e.print(os, 0); | |
| return os; | | return os; | |
| } | | } | |
| | | | |
| inline entry::data_type entry::type() const | | inline entry::data_type entry::type() const | |
| { | | { | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| m_type_queried = true; | | m_type_queried = true; | |
| #endif | | #endif | |
| return m_type; | | return m_type; | |
| } | | } | |
| | | | |
| inline entry::~entry() { destruct(); } | | inline entry::~entry() { destruct(); } | |
| | | | |
| inline void entry::operator=(const entry& e) | | inline void entry::operator=(const entry& e) | |
| { | | { | |
| destruct(); | | destruct(); | |
| copy(e); | | copy(e); | |
| } | | } | |
| | | | |
| inline entry::integer_type& entry::integer() | | inline entry::integer_type& entry::integer() | |
| { | | { | |
| if (m_type == undefined_t) construct(int_t); | | if (m_type == undefined_t) construct(int_t); | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| if (m_type != int_t) throw type_error("invalid type requeste
d from entry"); | | if (m_type != int_t) throw type_error("invalid type requeste
d from entry"); | |
|
| #elif !defined NDEBUG | | #elif defined TORRENT_DEBUG | |
| TORRENT_ASSERT(m_type_queried); | | TORRENT_ASSERT(m_type_queried); | |
| #endif | | #endif | |
| TORRENT_ASSERT(m_type == int_t); | | TORRENT_ASSERT(m_type == int_t); | |
| return *reinterpret_cast<integer_type*>(data); | | return *reinterpret_cast<integer_type*>(data); | |
| } | | } | |
| | | | |
| inline entry::integer_type const& entry::integer() const | | inline entry::integer_type const& entry::integer() const | |
| { | | { | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| if (m_type != int_t) throw type_error("invalid type requeste
d from entry"); | | if (m_type != int_t) throw type_error("invalid type requeste
d from entry"); | |
|
| #elif !defined NDEBUG | | #elif defined TORRENT_DEBUG | |
| TORRENT_ASSERT(m_type_queried); | | TORRENT_ASSERT(m_type_queried); | |
| #endif | | #endif | |
| TORRENT_ASSERT(m_type == int_t); | | TORRENT_ASSERT(m_type == int_t); | |
| return *reinterpret_cast<const integer_type*>(data); | | return *reinterpret_cast<const integer_type*>(data); | |
| } | | } | |
| | | | |
| inline entry::string_type& entry::string() | | inline entry::string_type& entry::string() | |
| { | | { | |
| if (m_type == undefined_t) construct(string_t); | | if (m_type == undefined_t) construct(string_t); | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| if (m_type != string_t) throw type_error("invalid type reque
sted from entry"); | | if (m_type != string_t) throw type_error("invalid type reque
sted from entry"); | |
|
| #elif !defined NDEBUG | | #elif defined TORRENT_DEBUG | |
| TORRENT_ASSERT(m_type_queried); | | TORRENT_ASSERT(m_type_queried); | |
| #endif | | #endif | |
| TORRENT_ASSERT(m_type == string_t); | | TORRENT_ASSERT(m_type == string_t); | |
| return *reinterpret_cast<string_type*>(data); | | return *reinterpret_cast<string_type*>(data); | |
| } | | } | |
| | | | |
| inline entry::string_type const& entry::string() const | | inline entry::string_type const& entry::string() const | |
| { | | { | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| if (m_type != string_t) throw type_error("invalid type reque
sted from entry"); | | if (m_type != string_t) throw type_error("invalid type reque
sted from entry"); | |
|
| #elif !defined NDEBUG | | #elif defined TORRENT_DEBUG | |
| TORRENT_ASSERT(m_type_queried); | | TORRENT_ASSERT(m_type_queried); | |
| #endif | | #endif | |
| TORRENT_ASSERT(m_type == string_t); | | TORRENT_ASSERT(m_type == string_t); | |
| return *reinterpret_cast<const string_type*>(data); | | return *reinterpret_cast<const string_type*>(data); | |
| } | | } | |
| | | | |
| inline entry::list_type& entry::list() | | inline entry::list_type& entry::list() | |
| { | | { | |
| if (m_type == undefined_t) construct(list_t); | | if (m_type == undefined_t) construct(list_t); | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| if (m_type != list_t) throw type_error("invalid type request
ed from entry"); | | if (m_type != list_t) throw type_error("invalid type request
ed from entry"); | |
|
| #elif !defined NDEBUG | | #elif defined TORRENT_DEBUG | |
| TORRENT_ASSERT(m_type_queried); | | TORRENT_ASSERT(m_type_queried); | |
| #endif | | #endif | |
| TORRENT_ASSERT(m_type == list_t); | | TORRENT_ASSERT(m_type == list_t); | |
| return *reinterpret_cast<list_type*>(data); | | return *reinterpret_cast<list_type*>(data); | |
| } | | } | |
| | | | |
| inline entry::list_type const& entry::list() const | | inline entry::list_type const& entry::list() const | |
| { | | { | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| if (m_type != list_t) throw type_error("invalid type request
ed from entry"); | | if (m_type != list_t) throw type_error("invalid type request
ed from entry"); | |
|
| #elif !defined NDEBUG | | #elif defined TORRENT_DEBUG | |
| TORRENT_ASSERT(m_type_queried); | | TORRENT_ASSERT(m_type_queried); | |
| #endif | | #endif | |
| TORRENT_ASSERT(m_type == list_t); | | TORRENT_ASSERT(m_type == list_t); | |
| return *reinterpret_cast<const list_type*>(data); | | return *reinterpret_cast<const list_type*>(data); | |
| } | | } | |
| | | | |
| inline entry::dictionary_type& entry::dict() | | inline entry::dictionary_type& entry::dict() | |
| { | | { | |
| if (m_type == undefined_t) construct(dictionary_t); | | if (m_type == undefined_t) construct(dictionary_t); | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| if (m_type != dictionary_t) throw type_error("invalid type r
equested from entry"); | | if (m_type != dictionary_t) throw type_error("invalid type r
equested from entry"); | |
|
| #elif !defined NDEBUG | | #elif defined TORRENT_DEBUG | |
| TORRENT_ASSERT(m_type_queried); | | TORRENT_ASSERT(m_type_queried); | |
| #endif | | #endif | |
| TORRENT_ASSERT(m_type == dictionary_t); | | TORRENT_ASSERT(m_type == dictionary_t); | |
| return *reinterpret_cast<dictionary_type*>(data); | | return *reinterpret_cast<dictionary_type*>(data); | |
| } | | } | |
| | | | |
| inline entry::dictionary_type const& entry::dict() const | | inline entry::dictionary_type const& entry::dict() const | |
| { | | { | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| if (m_type != dictionary_t) throw type_error("invalid type r
equested from entry"); | | if (m_type != dictionary_t) throw type_error("invalid type r
equested from entry"); | |
|
| #elif !defined NDEBUG | | #elif defined TORRENT_DEBUG | |
| TORRENT_ASSERT(m_type_queried); | | TORRENT_ASSERT(m_type_queried); | |
| #endif | | #endif | |
| TORRENT_ASSERT(m_type == dictionary_t); | | TORRENT_ASSERT(m_type == dictionary_t); | |
| return *reinterpret_cast<const dictionary_type*>(data); | | return *reinterpret_cast<const dictionary_type*>(data); | |
| } | | } | |
| | | | |
| } | | } | |
| | | | |
| #endif // TORRENT_ENTRY_HPP_INCLUDED | | #endif // TORRENT_ENTRY_HPP_INCLUDED | |
| | | | |
End of changes. 10 change blocks. |
| 10 lines changed or deleted | | 10 lines changed or added | |
|
| node.hpp | | node.hpp | |
| | | | |
| skipping to change at line 142 | | skipping to change at line 142 | |
| { | | { | |
| m.port = m_listen_port; | | m.port = m_listen_port; | |
| m.info_hash = m_info_hash; | | m.info_hash = m_info_hash; | |
| } | | } | |
| | | | |
| void timeout() {} | | void timeout() {} | |
| void reply(msg const& r) | | void reply(msg const& r) | |
| { | | { | |
| observer_ptr o(new (m_rpc.allocator().malloc()) announce_obs
erver( | | observer_ptr o(new (m_rpc.allocator().malloc()) announce_obs
erver( | |
| m_rpc.allocator(), m_info_hash, m_listen_port, r.wri
te_token)); | | m_rpc.allocator(), m_info_hash, m_listen_port, r.wri
te_token)); | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| o->m_in_constructor = false; | | o->m_in_constructor = false; | |
| #endif | | #endif | |
| m_rpc.invoke(messages::announce_peer, r.addr, o); | | m_rpc.invoke(messages::announce_peer, r.addr, o); | |
| m_fun(r.peers, m_info_hash); | | m_fun(r.peers, m_info_hash); | |
| } | | } | |
| void abort() {} | | void abort() {} | |
| | | | |
| private: | | private: | |
| sha1_hash m_info_hash; | | sha1_hash m_info_hash; | |
| int m_listen_port; | | int m_listen_port; | |
| rpc_manager& m_rpc; | | rpc_manager& m_rpc; | |
| boost::function<void(std::vector<tcp::endpoint> const&, sha1_hash co
nst&)> m_fun; | | boost::function<void(std::vector<tcp::endpoint> const&, sha1_hash co
nst&)> m_fun; | |
| }; | | }; | |
| | | | |
| class node_impl : boost::noncopyable | | class node_impl : boost::noncopyable | |
| { | | { | |
| typedef std::map<node_id, torrent_entry> table_t; | | typedef std::map<node_id, torrent_entry> table_t; | |
| public: | | public: | |
| node_impl(boost::function<void(msg const&)> const& f | | node_impl(boost::function<void(msg const&)> const& f | |
|
| , dht_settings const& settings); | | , dht_settings const& settings, boost::optional<node_id> nid
); | |
| | | | |
| virtual ~node_impl() {} | | virtual ~node_impl() {} | |
| | | | |
| void refresh(node_id const& id, boost::function0<void> f); | | void refresh(node_id const& id, boost::function0<void> f); | |
| void bootstrap(std::vector<udp::endpoint> const& nodes | | void bootstrap(std::vector<udp::endpoint> const& nodes | |
| , boost::function0<void> f); | | , boost::function0<void> f); | |
| void find_node(node_id const& id, boost::function< | | void find_node(node_id const& id, boost::function< | |
| void(std::vector<node_entry> const&)> f); | | void(std::vector<node_entry> const&)> f); | |
| void add_router_node(udp::endpoint router); | | void add_router_node(udp::endpoint router); | |
| | | | |
| | | | |
| skipping to change at line 187 | | skipping to change at line 187 | |
| void refresh_bucket(int bucket); | | void refresh_bucket(int bucket); | |
| int bucket_size(int bucket); | | int bucket_size(int bucket); | |
| | | | |
| typedef routing_table::iterator iterator; | | typedef routing_table::iterator iterator; | |
| | | | |
| iterator begin() const { return m_table.begin(); } | | iterator begin() const { return m_table.begin(); } | |
| iterator end() const { return m_table.end(); } | | iterator end() const { return m_table.end(); } | |
| | | | |
| typedef table_t::iterator data_iterator; | | typedef table_t::iterator data_iterator; | |
| | | | |
|
| void set_node_id(node_id const& nid) { m_id = nid; } | | | |
| node_id const& nid() const { return m_id; } | | node_id const& nid() const { return m_id; } | |
| | | | |
| boost::tuple<int, int> size() const{ return m_table.size(); } | | boost::tuple<int, int> size() const{ return m_table.size(); } | |
| size_type num_global_nodes() const | | size_type num_global_nodes() const | |
| { return m_table.num_global_nodes(); } | | { return m_table.num_global_nodes(); } | |
| | | | |
| data_iterator begin_data() { return m_map.begin(); } | | data_iterator begin_data() { return m_map.begin(); } | |
| data_iterator end_data() { return m_map.end(); } | | data_iterator end_data() { return m_map.end(); } | |
| int data_size() const { return int(m_map.size()); } | | int data_size() const { return int(m_map.size()); } | |
| | | | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 2 lines changed or added | |
|
| observer.hpp | | observer.hpp | |
| | | | |
| skipping to change at line 60 | | skipping to change at line 60 | |
| struct observer : boost::noncopyable | | struct observer : boost::noncopyable | |
| { | | { | |
| friend TORRENT_EXPORT void intrusive_ptr_add_ref(observer const*); | | friend TORRENT_EXPORT void intrusive_ptr_add_ref(observer const*); | |
| friend TORRENT_EXPORT void intrusive_ptr_release(observer const*); | | friend TORRENT_EXPORT void intrusive_ptr_release(observer const*); | |
| | | | |
| observer(boost::pool<>& p) | | observer(boost::pool<>& p) | |
| : sent(time_now()) | | : sent(time_now()) | |
| , pool_allocator(p) | | , pool_allocator(p) | |
| , m_refs(0) | | , m_refs(0) | |
| { | | { | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| m_in_constructor = true; | | m_in_constructor = true; | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| virtual ~observer() | | virtual ~observer() | |
| { | | { | |
| TORRENT_ASSERT(!m_in_constructor); | | TORRENT_ASSERT(!m_in_constructor); | |
| } | | } | |
| | | | |
| // these two callbacks lets the observer add | | // these two callbacks lets the observer add | |
| | | | |
| skipping to change at line 89 | | skipping to change at line 89 | |
| virtual void timeout() = 0; | | virtual void timeout() = 0; | |
| | | | |
| // if this is called the destructor should | | // if this is called the destructor should | |
| // not invoke any new messages, and should | | // not invoke any new messages, and should | |
| // only clean up. It means the rpc-manager | | // only clean up. It means the rpc-manager | |
| // is being destructed | | // is being destructed | |
| virtual void abort() = 0; | | virtual void abort() = 0; | |
| | | | |
| udp::endpoint target_addr; | | udp::endpoint target_addr; | |
| ptime sent; | | ptime sent; | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| bool m_in_constructor; | | bool m_in_constructor; | |
| #endif | | #endif | |
| private: | | private: | |
| boost::pool<>& pool_allocator; | | boost::pool<>& pool_allocator; | |
| // reference counter for intrusive_ptr | | // reference counter for intrusive_ptr | |
| mutable boost::detail::atomic_count m_refs; | | mutable boost::detail::atomic_count m_refs; | |
| }; | | }; | |
| | | | |
| typedef boost::intrusive_ptr<observer> observer_ptr; | | typedef boost::intrusive_ptr<observer> observer_ptr; | |
| | | | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| peer_connection.hpp | | peer_connection.hpp | |
| | | | |
| skipping to change at line 399 | | skipping to change at line 399 | |
| | | | |
| int max_assignable_bandwidth(int channel) const | | int max_assignable_bandwidth(int channel) const | |
| { return m_bandwidth_limit[channel].max_assignable(); } | | { return m_bandwidth_limit[channel].max_assignable(); } | |
| | | | |
| int bandwidth_throttle(int channel) const | | int bandwidth_throttle(int channel) const | |
| { return m_bandwidth_limit[channel].throttle(); } | | { return m_bandwidth_limit[channel].throttle(); } | |
| | | | |
| void assign_bandwidth(int channel, int amount); | | void assign_bandwidth(int channel, int amount); | |
| void expire_bandwidth(int channel, int amount); | | void expire_bandwidth(int channel, int amount); | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| void check_invariant() const; | | void check_invariant() const; | |
| ptime m_last_choke; | | ptime m_last_choke; | |
| #endif | | #endif | |
| | | | |
| // is true until we can be sure that the other end | | // is true until we can be sure that the other end | |
| // speaks our protocol (be it bittorrent or http). | | // speaks our protocol (be it bittorrent or http). | |
| virtual bool in_handshake() const = 0; | | virtual bool in_handshake() const = 0; | |
| | | | |
| // returns the block currently being | | // returns the block currently being | |
| // downloaded. And the progress of that | | // downloaded. And the progress of that | |
| | | | |
| skipping to change at line 460 | | skipping to change at line 460 | |
| { return m_send_buffer.size(); } | | { return m_send_buffer.size(); } | |
| | | | |
| int send_buffer_capacity() const | | int send_buffer_capacity() const | |
| { return m_send_buffer.capacity(); } | | { return m_send_buffer.capacity(); } | |
| | | | |
| int packet_size() const { return m_packet_size; } | | int packet_size() const { return m_packet_size; } | |
| | | | |
| bool packet_finished() const | | bool packet_finished() const | |
| { return m_packet_size <= m_recv_pos; } | | { return m_packet_size <= m_recv_pos; } | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| bool piece_failed; | | bool piece_failed; | |
| #endif | | #endif | |
| | | | |
| // 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]; | |
| | | | |
| protected: | | protected: | |
| | | | |
| virtual void get_specific_peer_info(peer_info& p) const = 0; | | virtual void get_specific_peer_info(peer_info& p) const = 0; | |
| | | | |
| skipping to change at line 568 | | skipping to change at line 568 | |
| #endif | | #endif | |
| | | | |
| #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES | | #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES | |
| // in case the session settings is set | | // in case the session settings is set | |
| // to resolve countries, this is set to | | // to resolve countries, this is set to | |
| // the two character country code this | | // the two character country code this | |
| // peer resides in. | | // peer resides in. | |
| char m_country[2]; | | char m_country[2]; | |
| #endif | | #endif | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| boost::intrusive_ptr<peer_connection> self() | | boost::intrusive_ptr<peer_connection> self() | |
| { | | { | |
| TORRENT_ASSERT(!m_in_constructor); | | TORRENT_ASSERT(!m_in_constructor); | |
| return intrusive_ptr_base<peer_connection>::self(); | | return intrusive_ptr_base<peer_connection>::self(); | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| private: | | private: | |
| | | | |
| void fill_send_buffer(); | | void fill_send_buffer(); | |
| | | | |
| skipping to change at line 872 | | skipping to change at line 872 | |
| bool m_upload_only:1; | | bool m_upload_only:1; | |
| | | | |
| // set to true when a piece request times out. The | | // set to true when a piece request times out. The | |
| // result is that the desired pending queue size | | // result is that the desired pending queue size | |
| // is set to 1 | | // is set to 1 | |
| bool m_snubbed:1; | | bool m_snubbed:1; | |
| | | | |
| // this is set to true once the bitfield is received | | // this is set to true once the bitfield is received | |
| bool m_bitfield_received:1; | | bool m_bitfield_received:1; | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| public: | | public: | |
| bool m_in_constructor:1; | | bool m_in_constructor:1; | |
| bool m_disconnect_started:1; | | bool m_disconnect_started:1; | |
| bool m_initialized:1; | | bool m_initialized:1; | |
| #endif | | #endif | |
| }; | | }; | |
| } | | } | |
| | | | |
| #endif // TORRENT_PEER_CONNECTION_HPP_INCLUDED | | #endif // TORRENT_PEER_CONNECTION_HPP_INCLUDED | |
| | | | |
End of changes. 4 change blocks. |
| 4 lines changed or deleted | | 4 lines changed or added | |
|
| piece_picker.hpp | | piece_picker.hpp | |
| | | | |
| skipping to change at line 311 | | skipping to change at line 311 | |
| void* get_downloader(piece_block block) const; | | void* get_downloader(piece_block block) const; | |
| | | | |
| // the number of filtered pieces we don't have | | // the number of filtered pieces we don't have | |
| int num_filtered() const { return m_num_filtered; } | | int num_filtered() const { return m_num_filtered; } | |
| | | | |
| // the number of filtered pieces we already have | | // the number of filtered pieces we already have | |
| int num_have_filtered() const { return m_num_have_filtered;
} | | int num_have_filtered() const { return m_num_have_filtered;
} | |
| | | | |
| int num_have() const { return m_num_have; } | | int num_have() const { return m_num_have; } | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| // used in debug mode | | // used in debug mode | |
| void verify_priority(int start, int end, int prio) const; | | void verify_priority(int start, int end, int prio) const; | |
| void check_invariant(const torrent* t = 0) const; | | void check_invariant(const torrent* t = 0) const; | |
| void verify_pick(std::vector<piece_block> const& picked | | void verify_pick(std::vector<piece_block> const& picked | |
| , bitfield const& bits) const; | | , bitfield const& bits) const; | |
| #endif | | #endif | |
|
| #if defined TORRENT_PICKER_LOG || !defined NDEBUG | | #if defined TORRENT_PICKER_LOG || defined TORRENT_DEBUG | |
| void print_pieces() const; | | void print_pieces() const; | |
| #endif | | #endif | |
| | | | |
| // functor that compares indices on downloading_pieces | | // functor that compares indices on downloading_pieces | |
| struct has_index | | struct has_index | |
| { | | { | |
| has_index(int i): index(i) { TORRENT_ASSERT(i >= 0);
} | | has_index(int i): index(i) { TORRENT_ASSERT(i >= 0);
} | |
| bool operator()(const downloading_piece& p) const | | bool operator()(const downloading_piece& p) const | |
| { return p.index == index; } | | { return p.index == index; } | |
| int index; | | int index; | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| policy.hpp | | policy.hpp | |
| | | | |
| skipping to change at line 113 | | skipping to change at line 113 | |
| void unchoked(peer_connection& c); | | void unchoked(peer_connection& c); | |
| | | | |
| // the peer is interested in our pieces | | // the peer is interested in our pieces | |
| void interested(peer_connection& c); | | void interested(peer_connection& c); | |
| | | | |
| // the peer is not interested in our pieces | | // the peer is not interested in our pieces | |
| void not_interested(peer_connection& c); | | void not_interested(peer_connection& c); | |
| | | | |
| void ip_filter_updated(); | | void ip_filter_updated(); | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| bool has_connection(const peer_connection* p); | | bool has_connection(const peer_connection* p); | |
| | | | |
| void check_invariant() const; | | void check_invariant() const; | |
| #endif | | #endif | |
| | | | |
| struct peer | | struct peer | |
| { | | { | |
| enum connection_type { not_connectable, connectable
}; | | enum connection_type { not_connectable, connectable
}; | |
| peer(tcp::endpoint const& ip, connection_type t, int
src); | | peer(tcp::endpoint const& ip, connection_type t, int
src); | |
| | | | |
| | | | |
| skipping to change at line 159 | | skipping to change at line 159 | |
| | | | |
| // the time when the peer connected to us | | // the time when the peer connected to us | |
| // or disconnected if it isn't connected right now | | // or disconnected if it isn't connected right now | |
| libtorrent::ptime connected; | | libtorrent::ptime connected; | |
| | | | |
| // if the peer is connected now, this | | // if the peer is connected now, this | |
| // will refer to a valid peer_connection | | // will refer to a valid peer_connection | |
| peer_connection* connection; | | peer_connection* connection; | |
| | | | |
| #ifndef TORRENT_DISABLE_GEO_IP | | #ifndef TORRENT_DISABLE_GEO_IP | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| // only used in debug mode to assert that | | // only used in debug mode to assert that | |
| // the first entry in the AS pair keeps the same | | // the first entry in the AS pair keeps the same | |
| boost::uint16_t inet_as_num; | | boost::uint16_t inet_as_num; | |
| #endif | | #endif | |
| // The AS this peer belongs to | | // The AS this peer belongs to | |
| std::pair<const int, int>* inet_as; | | std::pair<const int, int>* inet_as; | |
| #endif | | #endif | |
| | | | |
| // the port this peer is or was connected on | | // the port this peer is or was connected on | |
| boost::uint16_t port; | | boost::uint16_t port; | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| session_impl.hpp | | session_impl.hpp | |
| | | | |
| skipping to change at line 113 | | skipping to change at line 113 | |
| #endif | | #endif | |
| | | | |
| // this is the link between the main thread and the | | // this is the link between the main thread and the | |
| // thread started to run the main downloader loop | | // thread started to run the main downloader loop | |
| struct session_impl: boost::noncopyable | | struct session_impl: boost::noncopyable | |
| { | | { | |
| | | | |
| // the size of each allocation that is chained in th
e send buffer | | // the size of each allocation that is chained in th
e send buffer | |
| enum { send_buffer_size = 200 }; | | enum { send_buffer_size = 200 }; | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| friend class ::libtorrent::peer_connection; | | friend class ::libtorrent::peer_connection; | |
| #endif | | #endif | |
| friend struct checker_impl; | | friend struct checker_impl; | |
| friend class invariant_access; | | friend class invariant_access; | |
| typedef std::set<boost::intrusive_ptr<peer_connectio
n> > connection_map; | | typedef std::set<boost::intrusive_ptr<peer_connectio
n> > connection_map; | |
| typedef std::map<sha1_hash, boost::shared_ptr<torren
t> > torrent_map; | | typedef std::map<sha1_hash, boost::shared_ptr<torren
t> > torrent_map; | |
| | | | |
| session_impl( | | session_impl( | |
| std::pair<int, int> listen_port_range | | std::pair<int, int> listen_port_range | |
| , fingerprint const& cl_fprint | | , fingerprint const& cl_fprint | |
| | | | |
| skipping to change at line 135 | | skipping to change at line 135 | |
| #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined T
ORRENT_ERROR_LOGGING | | #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined T
ORRENT_ERROR_LOGGING | |
| , fs::path const& logpath | | , fs::path const& logpath | |
| #endif | | #endif | |
| ); | | ); | |
| ~session_impl(); | | ~session_impl(); | |
| | | | |
| #ifndef TORRENT_DISABLE_EXTENSIONS | | #ifndef TORRENT_DISABLE_EXTENSIONS | |
| void add_extension(boost::function<boost::shared_ptr
<torrent_plugin>( | | void add_extension(boost::function<boost::shared_ptr
<torrent_plugin>( | |
| torrent*, void*)> ext); | | torrent*, void*)> ext); | |
| #endif | | #endif | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| bool has_peer(peer_connection const* p) const | | bool has_peer(peer_connection const* p) const | |
| { | | { | |
| return std::find_if(m_connections.begin(), m
_connections.end() | | return std::find_if(m_connections.begin(), m
_connections.end() | |
| , boost::bind(&boost::intrusive_ptr<
peer_connection>::get, _1) == p) | | , boost::bind(&boost::intrusive_ptr<
peer_connection>::get, _1) == p) | |
| != m_connections.end(); | | != m_connections.end(); | |
| } | | } | |
| #endif | | #endif | |
| void operator()(); | | void operator()(); | |
| | | | |
| void open_listen_port(); | | void open_listen_port(); | |
| | | | |
| skipping to change at line 580 | | skipping to change at line 580 | |
| int m_tcp_mapping[2]; | | int m_tcp_mapping[2]; | |
| int m_udp_mapping[2]; | | int m_udp_mapping[2]; | |
| | | | |
| // the timer used to fire the second_tick | | // the timer used to fire the second_tick | |
| deadline_timer m_timer; | | deadline_timer m_timer; | |
| | | | |
| // the index of the torrent that will be offered to | | // the index of the torrent that will be offered to | |
| // connect to a peer next time second_tick is called
. | | // connect to a peer next time second_tick is called
. | |
| // This implements a round robin. | | // This implements a round robin. | |
| int m_next_connect_torrent; | | int m_next_connect_torrent; | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| void check_invariant() const; | | void check_invariant() const; | |
| #endif | | #endif | |
| | | | |
| #ifdef TORRENT_STATS | | #ifdef TORRENT_STATS | |
| // logger used to write bandwidth usage statistics | | // logger used to write bandwidth usage statistics | |
| std::ofstream m_stats_logger; | | std::ofstream m_stats_logger; | |
| int m_second_counter; | | int m_second_counter; | |
| // used to log send buffer usage statistics | | // used to log send buffer usage statistics | |
| std::ofstream m_buffer_usage_logger; | | std::ofstream m_buffer_usage_logger; | |
| // the number of send buffers that are allocated | | // the number of send buffers that are allocated | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 3 lines changed or added | |
|
| session_settings.hpp | | session_settings.hpp | |
| | | | |
| skipping to change at line 146 | | skipping to change at line 146 | |
| , seed_time_limit(24 * 60 * 60) // 24 hours | | , seed_time_limit(24 * 60 * 60) // 24 hours | |
| , peer_turnover(1 / 50.f) | | , peer_turnover(1 / 50.f) | |
| , peer_turnover_cutoff(1.f) | | , peer_turnover_cutoff(1.f) | |
| , close_redundant_connections(true) | | , close_redundant_connections(true) | |
| , auto_scrape_interval(1800) | | , auto_scrape_interval(1800) | |
| , auto_scrape_min_interval(300) | | , auto_scrape_min_interval(300) | |
| , max_peerlist_size(8000) | | , max_peerlist_size(8000) | |
| , min_announce_interval(5 * 60) | | , min_announce_interval(5 * 60) | |
| , prioritize_partial_pieces(false) | | , prioritize_partial_pieces(false) | |
| , auto_manage_startup(120) | | , auto_manage_startup(120) | |
|
| | | , rate_limit_ip_overhead(true) | |
| {} | | {} | |
| | | | |
| // this is the user agent that will be sent to the tracker | | // this is the user agent that will be sent to the tracker | |
| // when doing requests. It is used to identify the client. | | // when doing requests. It is used to identify the client. | |
| // It cannot contain \r or \n | | // It cannot contain \r or \n | |
| std::string user_agent; | | std::string user_agent; | |
| | | | |
| // the number of seconds to wait until giving up on a | | // the number of seconds to wait until giving up on a | |
| // tracker request if it hasn't finished | | // tracker request if it hasn't finished | |
| int tracker_completion_timeout; | | int tracker_completion_timeout; | |
| | | | |
| skipping to change at line 453 | | skipping to change at line 454 | |
| // that are more rare | | // that are more rare | |
| bool prioritize_partial_pieces; | | bool prioritize_partial_pieces; | |
| | | | |
| // the number of seconds a torrent is considered | | // the number of seconds a torrent is considered | |
| // active after it was started, regardless of | | // active after it was started, regardless of | |
| // upload and download speed. This is so that | | // upload and download speed. This is so that | |
| // newly started torrents are not considered | | // newly started torrents are not considered | |
| // inactive until they have a fair chance to | | // inactive until they have a fair chance to | |
| // start downloading. | | // start downloading. | |
| int auto_manage_startup; | | int auto_manage_startup; | |
|
| | | | |
| | | // if set to true, the estimated TCP/IP overhead is | |
| | | // drained from the rate limiters, to avoid exceeding | |
| | | // the limits with the total traffic | |
| | | bool rate_limit_ip_overhead; | |
| }; | | }; | |
| | | | |
| #ifndef TORRENT_DISABLE_DHT | | #ifndef TORRENT_DISABLE_DHT | |
| struct dht_settings | | struct dht_settings | |
| { | | { | |
| dht_settings() | | dht_settings() | |
| : max_peers_reply(50) | | : max_peers_reply(50) | |
| , search_branching(5) | | , search_branching(5) | |
| , service_port(0) | | , service_port(0) | |
| , max_fail_count(20) | | , max_fail_count(20) | |
| | | | |
End of changes. 2 change blocks. |
| 0 lines changed or deleted | | 6 lines changed or added | |
|
| storage.hpp | | storage.hpp | |
| | | | |
| skipping to change at line 238 | | skipping to change at line 238 | |
| peer_request const& r | | peer_request const& r | |
| , disk_buffer_holder& buffer | | , disk_buffer_holder& buffer | |
| , boost::function<void(int, disk_io_job const&)> con
st& f); | | , boost::function<void(int, disk_io_job const&)> con
st& f); | |
| | | | |
| void async_hash(int piece, boost::function<void(int, disk_io
_job const&)> const& f); | | void async_hash(int piece, boost::function<void(int, disk_io
_job const&)> const& f); | |
| | | | |
| void async_release_files( | | void async_release_files( | |
| boost::function<void(int, disk_io_job const&)> const
& handler | | boost::function<void(int, disk_io_job const&)> const
& handler | |
| = boost::function<void(int, disk_io_job const&)>()); | | = boost::function<void(int, disk_io_job const&)>()); | |
| | | | |
|
| | | void abort_disk_io(); | |
| | | | |
| void async_clear_read_cache( | | void async_clear_read_cache( | |
| boost::function<void(int, disk_io_job const&)> const
& handler | | boost::function<void(int, disk_io_job const&)> const
& handler | |
| = boost::function<void(int, disk_io_job const&)>()); | | = boost::function<void(int, disk_io_job const&)>()); | |
| | | | |
| void async_delete_files( | | void async_delete_files( | |
| boost::function<void(int, disk_io_job const&)> const
& handler | | boost::function<void(int, disk_io_job const&)> const
& handler | |
| = boost::function<void(int, disk_io_job const&)>()); | | = boost::function<void(int, disk_io_job const&)>()); | |
| | | | |
| void async_move_storage(fs::path const& p | | void async_move_storage(fs::path const& p | |
| , boost::function<void(int, disk_io_job const&)> con
st& handler); | | , boost::function<void(int, disk_io_job const&)> con
st& handler); | |
| | | | |
| skipping to change at line 298 | | skipping to change at line 300 | |
| // if 'fatal_disk_error' is returned, the error message indi
cates what | | // if 'fatal_disk_error' is returned, the error message indi
cates what | |
| // when wrong in the disk access | | // when wrong in the disk access | |
| int check_fastresume(lazy_entry const& rd, std::string& erro
r); | | int check_fastresume(lazy_entry const& rd, std::string& erro
r); | |
| | | | |
| // this function returns true if the checking is complete | | // this function returns true if the checking is complete | |
| int check_files(int& current_slot, int& have_piece, std::str
ing& error); | | int check_files(int& current_slot, int& have_piece, std::str
ing& error); | |
| | | | |
| bool compact_allocation() const | | bool compact_allocation() const | |
| { return m_storage_mode == storage_mode_compact; } | | { return m_storage_mode == storage_mode_compact; } | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| std::string name() const { return m_info->name(); } | | std::string name() const { return m_info->name(); } | |
| #endif | | #endif | |
| | | | |
| bool allocate_slots(int num_slots, bool abort_on_disk = fals
e); | | bool allocate_slots(int num_slots, bool abort_on_disk = fals
e); | |
| | | | |
| int read_impl( | | int read_impl( | |
| char* buf | | char* buf | |
| , int piece_index | | , int piece_index | |
| , int offset | | , int offset | |
| , int size); | | , int size); | |
| | | | |
| skipping to change at line 333 | | skipping to change at line 335 | |
| sha1_hash hash_for_piece_impl(int piece); | | sha1_hash hash_for_piece_impl(int piece); | |
| | | | |
| int release_files_impl() { return m_storage->release_files()
; } | | int release_files_impl() { return m_storage->release_files()
; } | |
| int delete_files_impl() { return m_storage->delete_files();
} | | int delete_files_impl() { return m_storage->delete_files();
} | |
| int rename_file_impl(int index, std::string const& new_filen
ame) | | int rename_file_impl(int index, std::string const& new_filen
ame) | |
| { return m_storage->rename_file(index, new_filename); } | | { return m_storage->rename_file(index, new_filename); } | |
| | | | |
| int move_storage_impl(fs::path const& save_path); | | int move_storage_impl(fs::path const& save_path); | |
| | | | |
| int allocate_slot_for_piece(int piece_index); | | int allocate_slot_for_piece(int piece_index); | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| void check_invariant() const; | | void check_invariant() const; | |
| #ifdef TORRENT_STORAGE_DEBUG | | #ifdef TORRENT_STORAGE_DEBUG | |
| void debug_log() const; | | void debug_log() const; | |
| #endif | | #endif | |
| #endif | | #endif | |
| boost::intrusive_ptr<torrent_info const> m_info; | | boost::intrusive_ptr<torrent_info const> m_info; | |
| file_storage const& m_files; | | file_storage const& m_files; | |
| | | | |
| boost::scoped_ptr<storage_interface> m_storage; | | boost::scoped_ptr<storage_interface> m_storage; | |
| | | | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 4 lines changed or added | |
|
| time.hpp | | time.hpp | |
| | | | |
| skipping to change at line 285 | | skipping to change at line 285 | |
| namespace libtorrent | | namespace libtorrent | |
| { | | { | |
| namespace aux | | namespace aux | |
| { | | { | |
| inline boost::int64_t performance_counter_to_microseconds(bo
ost::int64_t pc) | | inline boost::int64_t performance_counter_to_microseconds(bo
ost::int64_t pc) | |
| { | | { | |
| static LARGE_INTEGER performace_counter_frequency =
{0,0}; | | static LARGE_INTEGER performace_counter_frequency =
{0,0}; | |
| if (performace_counter_frequency.QuadPart == 0) | | if (performace_counter_frequency.QuadPart == 0) | |
| QueryPerformanceFrequency(&performace_counte
r_frequency); | | QueryPerformanceFrequency(&performace_counte
r_frequency); | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| // make sure we don't overflow | | // make sure we don't overflow | |
| boost::int64_t ret = (pc * 1000 / performace_counter
_frequency.QuadPart) * 1000; | | boost::int64_t ret = (pc * 1000 / performace_counter
_frequency.QuadPart) * 1000; | |
| TORRENT_ASSERT((pc >= 0 && pc >= ret) || (pc < 0 &&
pc < ret)); | | TORRENT_ASSERT((pc >= 0 && pc >= ret) || (pc < 0 &&
pc < ret)); | |
| #endif | | #endif | |
| return (pc * 1000 / performace_counter_frequency.Qua
dPart) * 1000; | | return (pc * 1000 / performace_counter_frequency.Qua
dPart) * 1000; | |
| } | | } | |
| | | | |
| inline boost::int64_t microseconds_to_performance_counter(bo
ost::int64_t ms) | | inline boost::int64_t microseconds_to_performance_counter(bo
ost::int64_t ms) | |
| { | | { | |
| static LARGE_INTEGER performace_counter_frequency =
{0,0}; | | static LARGE_INTEGER performace_counter_frequency =
{0,0}; | |
| if (performace_counter_frequency.QuadPart == 0) | | if (performace_counter_frequency.QuadPart == 0) | |
| QueryPerformanceFrequency(&performace_counte
r_frequency); | | QueryPerformanceFrequency(&performace_counte
r_frequency); | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| // make sure we don't overflow | | // make sure we don't overflow | |
| boost::int64_t ret = (ms / 1000) * performace_counte
r_frequency.QuadPart / 1000; | | boost::int64_t ret = (ms / 1000) * performace_counte
r_frequency.QuadPart / 1000; | |
| TORRENT_ASSERT((ms >= 0 && ms <= ret) | | TORRENT_ASSERT((ms >= 0 && ms <= ret) | |
| || (ms < 0 && ms > ret)); | | || (ms < 0 && ms > ret)); | |
| #endif | | #endif | |
| return (ms / 1000) * performace_counter_frequency.Qu
adPart / 1000; | | return (ms / 1000) * performace_counter_frequency.Qu
adPart / 1000; | |
| } | | } | |
| } | | } | |
| | | | |
| inline int total_seconds(time_duration td) | | inline int total_seconds(time_duration td) | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| torrent.hpp | | torrent.hpp | |
| | | | |
| skipping to change at line 150 | | skipping to change at line 150 | |
| | | | |
| // starts the announce timer | | // starts the announce timer | |
| void start(); | | void start(); | |
| | | | |
| #ifndef TORRENT_DISABLE_EXTENSIONS | | #ifndef TORRENT_DISABLE_EXTENSIONS | |
| void add_extension(boost::shared_ptr<torrent_plugin>); | | void add_extension(boost::shared_ptr<torrent_plugin>); | |
| void add_extension(boost::function<boost::shared_ptr<torrent
_plugin>(torrent*, void*)> const& ext | | void add_extension(boost::function<boost::shared_ptr<torrent
_plugin>(torrent*, void*)> const& ext | |
| , void* userdata); | | , void* userdata); | |
| #endif | | #endif | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| bool has_peer(peer_connection* p) const | | bool has_peer(peer_connection* p) const | |
| { return m_connections.find(p) != m_connections.end(); } | | { return m_connections.find(p) != m_connections.end(); } | |
| #endif | | #endif | |
| | | | |
| // this is called when the torrent has metadata. | | // this is called when the torrent has metadata. | |
| // it will initialize the storage and the piece-picker | | // it will initialize the storage and the piece-picker | |
| void init(); | | void init(); | |
| | | | |
| void on_resume_data_checked(int ret, disk_io_job const& j); | | void on_resume_data_checked(int ret, disk_io_job const& j); | |
| void on_force_recheck(int ret, disk_io_job const& j); | | void on_force_recheck(int ret, disk_io_job const& j); | |
| | | | |
| skipping to change at line 434 | | skipping to change at line 434 | |
| } | | } | |
| | | | |
| // when we get a have message, this is called for that piece | | // when we get a have message, this is called for that piece | |
| void peer_has(int index) | | void peer_has(int index) | |
| { | | { | |
| if (m_picker.get()) | | if (m_picker.get()) | |
| { | | { | |
| TORRENT_ASSERT(!is_seed()); | | TORRENT_ASSERT(!is_seed()); | |
| m_picker->inc_refcount(index); | | m_picker->inc_refcount(index); | |
| } | | } | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| else | | else | |
| { | | { | |
| TORRENT_ASSERT(is_seed()); | | TORRENT_ASSERT(is_seed()); | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| // when we get a bitfield message, this is called for that p
iece | | // when we get a bitfield message, this is called for that p
iece | |
| void peer_has(bitfield const& bits) | | void peer_has(bitfield const& bits) | |
| { | | { | |
| if (m_picker.get()) | | if (m_picker.get()) | |
| { | | { | |
| TORRENT_ASSERT(!is_seed()); | | TORRENT_ASSERT(!is_seed()); | |
| m_picker->inc_refcount(bits); | | m_picker->inc_refcount(bits); | |
| } | | } | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| else | | else | |
| { | | { | |
| TORRENT_ASSERT(is_seed()); | | TORRENT_ASSERT(is_seed()); | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| void peer_has_all() | | void peer_has_all() | |
| { | | { | |
| if (m_picker.get()) | | if (m_picker.get()) | |
| { | | { | |
| TORRENT_ASSERT(!is_seed()); | | TORRENT_ASSERT(!is_seed()); | |
| m_picker->inc_refcount_all(); | | m_picker->inc_refcount_all(); | |
| } | | } | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| else | | else | |
| { | | { | |
| TORRENT_ASSERT(is_seed()); | | TORRENT_ASSERT(is_seed()); | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| void peer_lost(int index) | | void peer_lost(int index) | |
| { | | { | |
| if (m_picker.get()) | | if (m_picker.get()) | |
| { | | { | |
| TORRENT_ASSERT(!is_seed()); | | TORRENT_ASSERT(!is_seed()); | |
| m_picker->dec_refcount(index); | | m_picker->dec_refcount(index); | |
| } | | } | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| else | | else | |
| { | | { | |
| TORRENT_ASSERT(is_seed()); | | TORRENT_ASSERT(is_seed()); | |
| } | | } | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| int block_size() const { TORRENT_ASSERT(m_block_size > 0); r
eturn m_block_size; } | | int block_size() const { TORRENT_ASSERT(m_block_size > 0); r
eturn m_block_size; } | |
| peer_request to_req(piece_block const& p); | | peer_request to_req(piece_block const& p); | |
| | | | |
| | | | |
| skipping to change at line 599 | | skipping to change at line 599 | |
| | | | |
| void write_resume_data(entry& rd) const; | | void write_resume_data(entry& rd) const; | |
| void read_resume_data(lazy_entry const& rd); | | void read_resume_data(lazy_entry const& rd); | |
| | | | |
| // LOGGING | | // LOGGING | |
| #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined T
ORRENT_ERROR_LOGGING | | #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined T
ORRENT_ERROR_LOGGING | |
| virtual void debug_log(const std::string& line); | | virtual void debug_log(const std::string& line); | |
| #endif | | #endif | |
| | | | |
| // DEBUG | | // DEBUG | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| void check_invariant() const; | | void check_invariant() const; | |
| #endif | | #endif | |
| | | | |
| // -------------------------------------------- | | // -------------------------------------------- | |
| // RESOURCE MANAGEMENT | | // RESOURCE MANAGEMENT | |
| | | | |
| void set_peer_upload_limit(tcp::endpoint ip, int limit); | | void set_peer_upload_limit(tcp::endpoint ip, int limit); | |
| void set_peer_download_limit(tcp::endpoint ip, int limit); | | void set_peer_download_limit(tcp::endpoint ip, int limit); | |
| | | | |
| void set_upload_limit(int limit); | | void set_upload_limit(int limit); | |
| | | | |
| skipping to change at line 721 | | skipping to change at line 721 | |
| | | | |
| // this is a weak (non owninig) pointer to | | // this is a weak (non owninig) pointer to | |
| // the piece_manager. This is used after the torrent | | // the piece_manager. This is used after the torrent | |
| // has been aborted, and it can no longer own | | // has been aborted, and it can no longer own | |
| // the object. | | // the object. | |
| piece_manager* m_storage; | | piece_manager* m_storage; | |
| | | | |
| // the time of next tracker announce | | // the time of next tracker announce | |
| ptime m_next_tracker_announce; | | ptime m_next_tracker_announce; | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| public: | | public: | |
| #endif | | #endif | |
| std::set<peer_connection*> m_connections; | | std::set<peer_connection*> m_connections; | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| private: | | private: | |
| #endif | | #endif | |
| | | | |
| // The list of web seeds in this torrent. Seeds | | // The list of web seeds in this torrent. Seeds | |
| // with fatal errors are removed from the set | | // with fatal errors are removed from the set | |
| std::set<std::string> m_web_seeds; | | std::set<std::string> m_web_seeds; | |
| | | | |
| // a list of web seeds that have failed and are | | // a list of web seeds that have failed and are | |
| // waiting to be retried | | // waiting to be retried | |
| std::map<std::string, ptime> m_web_seeds_next_retry; | | std::map<std::string, ptime> m_web_seeds_next_retry; | |
| | | | |
| skipping to change at line 875 | | skipping to change at line 875 | |
| int m_block_size; | | int m_block_size; | |
| | | | |
| // ----------------------------- | | // ----------------------------- | |
| // DATA FROM TRACKER RESPONSE | | // DATA FROM TRACKER RESPONSE | |
| | | | |
| // the scrape data from the tracker response, this | | // the scrape data from the tracker response, this | |
| // is optional and may be -1. | | // is optional and may be -1. | |
| int m_complete; | | int m_complete; | |
| int m_incomplete; | | int m_incomplete; | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| // this is the amount downloaded when this torrent | | // this is the amount downloaded when this torrent | |
| // is started. i.e. | | // is started. i.e. | |
| // total_done - m_initial_done <= total_payload_download | | // total_done - m_initial_done <= total_payload_download | |
| size_type m_initial_done; | | size_type m_initial_done; | |
| #endif | | #endif | |
| // this is the deficit counter in the Deficit Round Robin | | // this is the deficit counter in the Deficit Round Robin | |
| // used to determine which torrent gets the next | | // used to determine which torrent gets the next | |
| // connection attempt. See: | | // connection attempt. See: | |
| // http://www.ecs.umass.edu/ece/wolf/courses/ECE697J/papers/
DRR.pdf | | // http://www.ecs.umass.edu/ece/wolf/courses/ECE697J/papers/
DRR.pdf | |
| // The quanta assigned to each torrent depends on the torren
ts | | // The quanta assigned to each torrent depends on the torren
ts | |
| | | | |
End of changes. 9 change blocks. |
| 9 lines changed or deleted | | 9 lines changed or added | |
|
| udp_socket.hpp | | udp_socket.hpp | |
| | | | |
| skipping to change at line 67 | | skipping to change at line 67 | |
| | | | |
| void send(udp::endpoint const& ep, char const* p, int len, e
rror_code& ec); | | void send(udp::endpoint const& ep, char const* p, int len, e
rror_code& ec); | |
| void bind(udp::endpoint const& ep, error_code& ec); | | void bind(udp::endpoint const& ep, error_code& ec); | |
| void bind(int port); | | void bind(int port); | |
| void close(); | | void close(); | |
| int local_port() const { return m_bind_port; } | | int local_port() const { return m_bind_port; } | |
| | | | |
| void set_proxy_settings(proxy_settings const& ps); | | void set_proxy_settings(proxy_settings const& ps); | |
| proxy_settings const& get_proxy_settings() { return m_proxy_
settings; } | | proxy_settings const& get_proxy_settings() { return m_proxy_
settings; } | |
| | | | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| ~udp_socket() { m_magic = 0; } | | ~udp_socket() { m_magic = 0; } | |
| #endif | | #endif | |
| | | | |
| private: | | private: | |
| | | | |
| callback_t m_callback; | | callback_t m_callback; | |
| | | | |
| void on_read(udp::socket* sock, error_code const& e, std::si
ze_t bytes_transferred); | | void on_read(udp::socket* sock, error_code const& e, std::si
ze_t bytes_transferred); | |
| void on_name_lookup(error_code const& e, tcp::resolver::iter
ator i); | | void on_name_lookup(error_code const& e, tcp::resolver::iter
ator i); | |
| void on_timeout(); | | void on_timeout(); | |
| | | | |
| skipping to change at line 111 | | skipping to change at line 111 | |
| char m_outstanding; | | char m_outstanding; | |
| | | | |
| tcp::socket m_socks5_sock; | | tcp::socket m_socks5_sock; | |
| int m_connection_ticket; | | int m_connection_ticket; | |
| proxy_settings m_proxy_settings; | | proxy_settings m_proxy_settings; | |
| connection_queue& m_cc; | | connection_queue& m_cc; | |
| tcp::resolver m_resolver; | | tcp::resolver m_resolver; | |
| char m_tmp_buf[100]; | | char m_tmp_buf[100]; | |
| bool m_tunnel_packets; | | bool m_tunnel_packets; | |
| udp::endpoint m_proxy_addr; | | udp::endpoint m_proxy_addr; | |
|
| #ifndef NDEBUG | | #ifdef TORRENT_DEBUG | |
| int m_magic; | | int m_magic; | |
| #endif | | #endif | |
| }; | | }; | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|