| broadcast_socket.hpp | | broadcast_socket.hpp | |
| | | | |
| skipping to change at line 72 | | skipping to change at line 72 | |
| class TORRENT_EXPORT broadcast_socket | | class TORRENT_EXPORT broadcast_socket | |
| { | | { | |
| public: | | public: | |
| broadcast_socket(io_service& ios, udp::endpoint const& multi
cast_endpoint | | broadcast_socket(io_service& ios, udp::endpoint const& multi
cast_endpoint | |
| , receive_handler_t const& handler, bool loopback =
true); | | , receive_handler_t const& handler, bool loopback =
true); | |
| ~broadcast_socket() { close(); } | | ~broadcast_socket() { close(); } | |
| | | | |
| void send(char const* buffer, int size, error_code& ec); | | void send(char const* buffer, int size, error_code& ec); | |
| void close(); | | void close(); | |
| int num_send_sockets() const { return m_unicast_sockets.size
(); } | | int num_send_sockets() const { return m_unicast_sockets.size
(); } | |
|
| | | void enable_ip_broadcast(bool e); | |
| | | | |
| private: | | private: | |
| | | | |
| struct socket_entry | | struct socket_entry | |
| { | | { | |
|
| socket_entry(boost::shared_ptr<datagram_socket> cons | | socket_entry(boost::shared_ptr<datagram_socket> cons | |
| t& s): socket(s) {} | | t& s) | |
| | | : socket(s) {} | |
| | | socket_entry(boost::shared_ptr<datagram_socket> cons | |
| | | t& s | |
| | | , address_v4 const& mask): socket(s), netmas | |
| | | k(mask) {} | |
| boost::shared_ptr<datagram_socket> socket; | | boost::shared_ptr<datagram_socket> socket; | |
| char buffer[1024]; | | char buffer[1024]; | |
| udp::endpoint remote; | | udp::endpoint remote; | |
|
| | | address_v4 netmask; | |
| void close() | | void close() | |
| { | | { | |
| if (!socket) return; | | if (!socket) return; | |
| error_code ec; | | error_code ec; | |
| socket->close(ec); | | socket->close(ec); | |
| } | | } | |
|
| | | address_v4 broadcast_address() const | |
| | | { | |
| | | error_code ec; | |
| | | return address_v4::broadcast(socket->local_e | |
| | | ndpoint(ec).address().to_v4(), netmask); | |
| | | } | |
| }; | | }; | |
| | | | |
| void on_receive(socket_entry* s, error_code const& ec | | void on_receive(socket_entry* s, error_code const& ec | |
| , std::size_t bytes_transferred); | | , std::size_t bytes_transferred); | |
|
| void open_unicast_socket(io_service& ios, address const& add | | void open_unicast_socket(io_service& ios, address const& add | |
| r); | | r | |
| | | , address_v4 const& mask); | |
| void open_multicast_socket(io_service& ios, address const& a
ddr | | void open_multicast_socket(io_service& ios, address const& a
ddr | |
| , bool loopback, error_code& ec); | | , bool loopback, error_code& ec); | |
| | | | |
| // these sockets are used to | | // these sockets are used to | |
| // join the multicast group (on each interface) | | // join the multicast group (on each interface) | |
| // and receive multicast messages | | // and receive multicast messages | |
| std::list<socket_entry> m_sockets; | | std::list<socket_entry> m_sockets; | |
| // these sockets are not bound to any | | // these sockets are not bound to any | |
| // specific port and are used to | | // specific port and are used to | |
| // send messages to the multicast group | | // send messages to the multicast group | |
| // and receive unicast responses | | // and receive unicast responses | |
| std::list<socket_entry> m_unicast_sockets; | | std::list<socket_entry> m_unicast_sockets; | |
| udp::endpoint m_multicast_endpoint; | | udp::endpoint m_multicast_endpoint; | |
| receive_handler_t m_on_receive; | | receive_handler_t m_on_receive; | |
| | | | |
|
| | | // if set, use IP broadcast as well as IP multicast | |
| | | // this is off by default because it's expensive in | |
| | | // terms of bandwidth usage | |
| | | bool m_ip_broadcast; | |
| | | | |
| }; | | }; | |
| } | | } | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 6 change blocks. |
| 4 lines changed or deleted | | 23 lines changed or added | |
|
| create_torrent.hpp | | create_torrent.hpp | |
| | | | |
| skipping to change at line 194 | | skipping to change at line 194 | |
| std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem:
:wpath const& p); | | std::time_t TORRENT_EXPORT get_file_mtime(boost::filesystem:
:wpath const& p); | |
| #endif | | #endif | |
| | | | |
| fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem::
path const& p); | | fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem::
path const& p); | |
| #if TORRENT_USE_WPATH | | #if TORRENT_USE_WPATH | |
| fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem::
wpath const& p); | | fs::path TORRENT_EXPORT get_symlink_path(boost::filesystem::
wpath const& p); | |
| #endif | | #endif | |
| | | | |
| template <class Pred, class Str, class PathTraits> | | template <class Pred, class Str, class PathTraits> | |
| void add_files_impl(file_storage& fs, boost::filesystem::bas
ic_path<Str, PathTraits> const& p | | void add_files_impl(file_storage& fs, boost::filesystem::bas
ic_path<Str, PathTraits> const& p | |
|
| , boost::filesystem::basic_path<Str, PathTraits> con
st& l, Pred pred) | | , boost::filesystem::basic_path<Str, PathTraits> con
st& l, Pred pred, boost::uint32_t flags) | |
| { | | { | |
| using boost::filesystem::basic_path; | | using boost::filesystem::basic_path; | |
| using boost::filesystem::basic_directory_iterator; | | using boost::filesystem::basic_directory_iterator; | |
| basic_path<Str, PathTraits> f(p / l); | | basic_path<Str, PathTraits> f(p / l); | |
| if (!pred(f)) return; | | if (!pred(f)) return; | |
|
| if (is_directory(f)) | | | |
| | | bool recurse = is_directory(f); | |
| | | // if the file is not a link or we're following link | |
| | | s, and it's a directory | |
| | | // only then should we recurse | |
| | | if ((is_symlink(f)) && (flags & create_torrent::syml | |
| | | inks)) | |
| | | recurse = false; | |
| | | | |
| | | if (recurse) | |
| { | | { | |
| for (basic_directory_iterator<basic_path<Str
, PathTraits> > i(f), end; i != end; ++i) | | for (basic_directory_iterator<basic_path<Str
, PathTraits> > i(f), end; i != end; ++i) | |
| { | | { | |
| #if BOOST_VERSION < 103600 | | #if BOOST_VERSION < 103600 | |
| Str const& leaf = i->path().leaf(); | | Str const& leaf = i->path().leaf(); | |
| #else | | #else | |
| Str const& leaf = i->path().filename
(); | | Str const& leaf = i->path().filename
(); | |
| #endif | | #endif | |
| if (ignore_subdir(leaf)) continue; | | if (ignore_subdir(leaf)) continue; | |
|
| add_files_impl(fs, p, l / leaf, pred
); | | add_files_impl(fs, p, l / leaf, pred
, flags); | |
| } | | } | |
| } | | } | |
| else | | else | |
| { | | { | |
| int file_flags = get_file_attributes(f); | | int file_flags = get_file_attributes(f); | |
| std::time_t mtime = get_file_mtime(f); | | std::time_t mtime = get_file_mtime(f); | |
| //Masking all bits to check if the file is a
symlink | | //Masking all bits to check if the file is a
symlink | |
|
| if(file_flags & file_storage::attribute_syml | | if ((file_flags & file_storage::attribute_sy | |
| ink) | | mlink) | |
| | | && (flags & create_torrent::symlinks | |
| | | )) | |
| { | | { | |
| fs::path sym_path = get_symlink_path
(f); | | fs::path sym_path = get_symlink_path
(f); | |
| fs.add_file(l, 0 ,file_flags, mtime,
sym_path); | | fs.add_file(l, 0 ,file_flags, mtime,
sym_path); | |
| } | | } | |
| else | | else | |
| { | | { | |
| fs.add_file(l, file_size(f), file_fl
ags, mtime); | | fs.add_file(l, file_size(f), file_fl
ags, mtime); | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| // path versions | | // path versions | |
| | | | |
| template <class Pred> | | template <class Pred> | |
|
| void add_files(file_storage& fs, boost::filesystem::path const& file | | void add_files(file_storage& fs, boost::filesystem::path const& file | |
| , Pred p) | | , Pred p | |
| | | , boost::uint32_t flags = 0) | |
| { | | { | |
| using boost::filesystem::path; | | using boost::filesystem::path; | |
| boost::filesystem::path f = file; | | boost::filesystem::path f = file; | |
| #if BOOST_VERSION < 103600 | | #if BOOST_VERSION < 103600 | |
| if (f.leaf() == ".") f = f.branch_path(); | | if (f.leaf() == ".") f = f.branch_path(); | |
|
| detail::add_files_impl(fs, complete(f).branch_path(), path(f
.leaf()), p); | | detail::add_files_impl(fs, complete(f).branch_path(), path(f
.leaf()), p, flags); | |
| #else | | #else | |
| if (f.filename() == ".") f = f.parent_path(); | | if (f.filename() == ".") f = f.parent_path(); | |
|
| detail::add_files_impl(fs, complete(f).parent_path(), path(f
.filename()), p); | | detail::add_files_impl(fs, complete(f).parent_path(), path(f
.filename()), p, flags); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
|
| inline void add_files(file_storage& fs, boost::filesystem::path cons | | inline void add_files(file_storage& fs, boost::filesystem::path cons | |
| t& file) | | t& file | |
| | | , boost::uint32_t flags = 0) | |
| { | | { | |
| using boost::filesystem::path; | | using boost::filesystem::path; | |
| boost::filesystem::path f = file; | | boost::filesystem::path f = file; | |
| #if BOOST_VERSION < 103600 | | #if BOOST_VERSION < 103600 | |
| if (f.leaf() == ".") f = f.branch_path(); | | if (f.leaf() == ".") f = f.branch_path(); | |
|
| detail::add_files_impl(fs, complete(f).branch_path(), path(f | | detail::add_files_impl(fs, complete(f).branch_path(), path(f | |
| .leaf()), detail::default_pred); | | .leaf()) | |
| | | , detail::default_pred, flags); | |
| #else | | #else | |
| if (f.filename() == ".") f = f.parent_path(); | | if (f.filename() == ".") f = f.parent_path(); | |
|
| detail::add_files_impl(fs, complete(f).parent_path(), path(f | | detail::add_files_impl(fs, complete(f).parent_path(), path(f | |
| .filename()), detail::default_pred); | | .filename()) | |
| | | , detail::default_pred, flags); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| struct piece_holder | | struct piece_holder | |
| { | | { | |
| piece_holder(int bytes): m_piece(page_aligned_allocator::mal
loc(bytes)) {} | | piece_holder(int bytes): m_piece(page_aligned_allocator::mal
loc(bytes)) {} | |
| ~piece_holder() { page_aligned_allocator::free(m_piece); } | | ~piece_holder() { page_aligned_allocator::free(m_piece); } | |
| char* bytes() { return m_piece; } | | char* bytes() { return m_piece; } | |
| private: | | private: | |
| char* m_piece; | | char* m_piece; | |
| | | | |
| skipping to change at line 322 | | skipping to change at line 334 | |
| | | | |
| inline void set_piece_hashes(create_torrent& t, boost::filesystem::p
ath const& p, error_code& ec) | | inline void set_piece_hashes(create_torrent& t, boost::filesystem::p
ath const& p, error_code& ec) | |
| { | | { | |
| set_piece_hashes(t, p, detail::nop, ec); | | set_piece_hashes(t, p, detail::nop, ec); | |
| } | | } | |
| | | | |
| #if TORRENT_USE_WPATH | | #if TORRENT_USE_WPATH | |
| // wpath versions | | // wpath versions | |
| | | | |
| template <class Pred> | | template <class Pred> | |
|
| void add_files(file_storage& fs, boost::filesystem::wpath const& fil | | void add_files(file_storage& fs, boost::filesystem::wpath const& fil | |
| e, Pred p) | | e, Pred p | |
| | | , boost::uint32_t flags = 0) | |
| { | | { | |
| using boost::filesystem::wpath; | | using boost::filesystem::wpath; | |
| wpath f = file; | | wpath f = file; | |
| #if BOOST_VERSION < 103600 | | #if BOOST_VERSION < 103600 | |
| if (f.leaf() == L".") f = f.branch_path(); | | if (f.leaf() == L".") f = f.branch_path(); | |
|
| detail::add_files_impl(fs, complete(f).branch_path(), wpath(
f.leaf()), p); | | detail::add_files_impl(fs, complete(f).branch_path(), wpath(
f.leaf()), p, flags); | |
| #else | | #else | |
| if (f.filename() == L".") f = f.parent_path(); | | if (f.filename() == L".") f = f.parent_path(); | |
|
| detail::add_files_impl(fs, complete(f).parent_path(), wpath(
f.filename()), p); | | detail::add_files_impl(fs, complete(f).parent_path(), wpath(
f.filename()), p, flags); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
|
| inline void add_files(file_storage& fs, boost::filesystem::wpath con | | inline void add_files(file_storage& fs, boost::filesystem::wpath con | |
| st& file) | | st& file | |
| | | , boost::uint32_t flags = 0) | |
| { | | { | |
| using boost::filesystem::wpath; | | using boost::filesystem::wpath; | |
| wpath f = file; | | wpath f = file; | |
| #if BOOST_VERSION < 103600 | | #if BOOST_VERSION < 103600 | |
| if (f.leaf() == L".") f = f.branch_path(); | | if (f.leaf() == L".") f = f.branch_path(); | |
|
| detail::add_files_impl(fs, complete(f).branch_path(), wpath( | | detail::add_files_impl(fs, complete(f).branch_path(), wpath( | |
| f.leaf()), detail::wdefault_pred); | | f.leaf()), detail::wdefault_pred | |
| | | , flags); | |
| #else | | #else | |
| if (f.filename() == L".") f = f.parent_path(); | | if (f.filename() == L".") f = f.parent_path(); | |
|
| detail::add_files_impl(fs, complete(f).parent_path(), wpath( | | detail::add_files_impl(fs, complete(f).parent_path(), wpath( | |
| f.filename()), detail::wdefault_pred); | | f.filename()) | |
| | | , detail::wdefault_pred, flags); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| template <class Fun> | | template <class Fun> | |
| void set_piece_hashes(create_torrent& t, boost::filesystem::wpath co
nst& p, Fun f | | void set_piece_hashes(create_torrent& t, boost::filesystem::wpath co
nst& p, Fun f | |
| , error_code& ec) | | , error_code& ec) | |
| { | | { | |
| file_pool fp; | | file_pool fp; | |
| std::string utf8; | | std::string utf8; | |
| wchar_utf8(p.string(), utf8); | | wchar_utf8(p.string(), utf8); | |
| | | | |
End of changes. 16 change blocks. |
| 25 lines changed or deleted | | 44 lines changed or added | |
|
| entry.hpp | | entry.hpp | |
| | | | |
| skipping to change at line 190 | | skipping to change at line 190 | |
| #endif | | #endif | |
| | | | |
| protected: | | protected: | |
| | | | |
| void construct(data_type t); | | void construct(data_type t); | |
| void copy(const entry& e); | | void copy(const entry& e); | |
| void destruct(); | | void destruct(); | |
| | | | |
| private: | | private: | |
| | | | |
|
| | | #ifndef TORRENT_DEBUG | |
| data_type m_type; | | data_type m_type; | |
|
| | | | |
| #if (defined(_MSC_VER) && _MSC_VER < 1310) || TORRENT_COMPLETE_TYPES_REQUIR | | | |
| ED | | | |
| // workaround for msvc-bug. | | | |
| // assumes sizeof(map<string, char>) == sizeof(map<string, e | | | |
| ntry>) | | | |
| // and sizeof(list<char>) == sizeof(list<entry>) | | | |
| union | | | |
| { | | | |
| char data[ | | | |
| detail::max4<sizeof(std::list<char>) | | | |
| , sizeof(std::map<std::string, char>) | | | |
| , sizeof(string_type) | | | |
| , sizeof(integer_type)>::value]; | | | |
| integer_type dummy_aligner; | | | |
| }; | | | |
| #else | | #else | |
|
| union | | // the bitfield is used so that the m_type_queried | |
| { | | // field still fits, so that the ABI is the same for | |
| char data[detail::max4<sizeof(list_type) | | // debug builds and release builds. It appears to be | |
| , sizeof(dictionary_type) | | // very hard to match debug builds with debug versions | |
| , sizeof(string_type) | | // of libtorrent | |
| , sizeof(integer_type)>::value]; | | data_type m_type:31; | |
| integer_type dummy_aligner; | | | |
| }; | | | |
| #endif | | | |
| | | | |
|
| #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:1; | |
| | | protected: | |
| | | #endif // TORRENT_DEBUG | |
| | | | |
| | | #if (defined(_MSC_VER) && _MSC_VER < 1310) || TORRENT_COMPLETE_TYPES_REQUIR | |
| | | ED | |
| | | // workaround for msvc-bug. | |
| | | // assumes sizeof(map<string, char>) == sizeof(map<string, e | |
| | | ntry>) | |
| | | // and sizeof(list<char>) == sizeof(list<entry>) | |
| | | enum { union_size | |
| | | = detail::max4<sizeof(std::list<char>) | |
| | | , sizeof(std::map<std::string, char>) | |
| | | , sizeof(string_type) | |
| | | , sizeof(integer_type)>::value | |
| | | }; | |
| | | #else | |
| | | enum { union_size | |
| | | = detail::max4<sizeof(list_type) | |
| | | , sizeof(dictionary_type) | |
| | | , sizeof(string_type) | |
| | | , sizeof(integer_type)>::value | |
| | | }; | |
| #endif | | #endif | |
|
| | | | |
| | | integer_type data[(union_size + sizeof(integer_type) - 1) | |
| | | / sizeof(integer_type)]; | |
| }; | | }; | |
| | | | |
| #if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM | | #if defined TORRENT_DEBUG && TORRENT_USE_IOSTREAM | |
| 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; | |
| } | | } | |
| #endif | | #endif | |
| | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | #ifndef BOOST_NO_EXCEPTIONS | |
| inline void throw_type_error() | | inline void throw_type_error() | |
| { | | { | |
| throw libtorrent_exception(error_code(errors::invalid_entry_
type | | throw libtorrent_exception(error_code(errors::invalid_entry_
type | |
| , get_libtorrent_category())); | | , get_libtorrent_category())); | |
| } | | } | |
| #endif | | #endif | |
| | | | |
|
| inline entry::data_type entry::type() const | | | |
| { | | | |
| #ifdef TORRENT_DEBUG | | | |
| m_type_queried = true; | | | |
| #endif | | | |
| return m_type; | | | |
| } | | | |
| | | | |
| inline entry::~entry() { destruct(); } | | | |
| | | | |
| inline void entry::operator=(const entry& e) | | | |
| { | | | |
| destruct(); | | | |
| copy(e); | | | |
| } | | | |
| | | | |
| inline entry::integer_type& entry::integer() | | | |
| { | | | |
| if (m_type == undefined_t) construct(int_t); | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | | |
| if (m_type != int_t) throw_type_error(); | | | |
| #elif defined TORRENT_DEBUG | | | |
| TORRENT_ASSERT(m_type_queried); | | | |
| #endif | | | |
| TORRENT_ASSERT(m_type == int_t); | | | |
| return *reinterpret_cast<integer_type*>(data); | | | |
| } | | | |
| | | | |
| inline entry::integer_type const& entry::integer() const | | | |
| { | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | | |
| if (m_type != int_t) throw_type_error(); | | | |
| #elif defined TORRENT_DEBUG | | | |
| TORRENT_ASSERT(m_type_queried); | | | |
| #endif | | | |
| TORRENT_ASSERT(m_type == int_t); | | | |
| return *reinterpret_cast<const integer_type*>(data); | | | |
| } | | | |
| | | | |
| inline entry::string_type& entry::string() | | | |
| { | | | |
| if (m_type == undefined_t) construct(string_t); | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | | |
| if (m_type != string_t) throw_type_error(); | | | |
| #elif defined TORRENT_DEBUG | | | |
| TORRENT_ASSERT(m_type_queried); | | | |
| #endif | | | |
| TORRENT_ASSERT(m_type == string_t); | | | |
| return *reinterpret_cast<string_type*>(data); | | | |
| } | | | |
| | | | |
| inline entry::string_type const& entry::string() const | | | |
| { | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | | |
| if (m_type != string_t) throw_type_error(); | | | |
| #elif defined TORRENT_DEBUG | | | |
| TORRENT_ASSERT(m_type_queried); | | | |
| #endif | | | |
| TORRENT_ASSERT(m_type == string_t); | | | |
| return *reinterpret_cast<const string_type*>(data); | | | |
| } | | | |
| | | | |
| inline entry::list_type& entry::list() | | | |
| { | | | |
| if (m_type == undefined_t) construct(list_t); | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | | |
| if (m_type != list_t) throw_type_error(); | | | |
| #elif defined TORRENT_DEBUG | | | |
| TORRENT_ASSERT(m_type_queried); | | | |
| #endif | | | |
| TORRENT_ASSERT(m_type == list_t); | | | |
| return *reinterpret_cast<list_type*>(data); | | | |
| } | | | |
| | | | |
| inline entry::list_type const& entry::list() const | | | |
| { | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | | |
| if (m_type != list_t) throw_type_error(); | | | |
| #elif defined TORRENT_DEBUG | | | |
| TORRENT_ASSERT(m_type_queried); | | | |
| #endif | | | |
| TORRENT_ASSERT(m_type == list_t); | | | |
| return *reinterpret_cast<const list_type*>(data); | | | |
| } | | | |
| | | | |
| inline entry::dictionary_type& entry::dict() | | | |
| { | | | |
| if (m_type == undefined_t) construct(dictionary_t); | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | | |
| if (m_type != dictionary_t) throw_type_error(); | | | |
| #elif defined TORRENT_DEBUG | | | |
| TORRENT_ASSERT(m_type_queried); | | | |
| #endif | | | |
| TORRENT_ASSERT(m_type == dictionary_t); | | | |
| return *reinterpret_cast<dictionary_type*>(data); | | | |
| } | | | |
| | | | |
| inline entry::dictionary_type const& entry::dict() const | | | |
| { | | | |
| #ifndef BOOST_NO_EXCEPTIONS | | | |
| if (m_type != dictionary_t) throw_type_error(); | | | |
| #elif defined TORRENT_DEBUG | | | |
| TORRENT_ASSERT(m_type_queried); | | | |
| #endif | | | |
| TORRENT_ASSERT(m_type == dictionary_t); | | | |
| return *reinterpret_cast<const dictionary_type*>(data); | | | |
| } | | | |
| | | | |
| } | | } | |
| | | | |
| #endif // TORRENT_ENTRY_HPP_INCLUDED | | #endif // TORRENT_ENTRY_HPP_INCLUDED | |
| | | | |
End of changes. 7 change blocks. |
| 135 lines changed or deleted | | 33 lines changed or added | |
|
| peer_connection.hpp | | peer_connection.hpp | |
| | | | |
| skipping to change at line 320 | | skipping to change at line 320 | |
| | | | |
| bitfield const& get_bitfield() const; | | bitfield const& get_bitfield() const; | |
| std::vector<int> const& allowed_fast(); | | std::vector<int> const& allowed_fast(); | |
| std::vector<int> const& suggested_pieces() const { return m_
suggested_pieces; } | | std::vector<int> const& suggested_pieces() const { return m_
suggested_pieces; } | |
| | | | |
| ptime connected_time() const { return m_connect; } | | ptime connected_time() const { return m_connect; } | |
| ptime last_received() const { return m_last_receive; } | | ptime last_received() const { return m_last_receive; } | |
| | | | |
| void on_timeout(); | | void on_timeout(); | |
| // this will cause this peer_connection to be disconnected. | | // this will cause this peer_connection to be disconnected. | |
|
| void disconnect(error_code const& ec, int error = 0); | | virtual void disconnect(error_code const& ec, int error = 0)
; | |
| bool is_disconnecting() const { return m_disconnecting; } | | bool is_disconnecting() const { return m_disconnecting; } | |
| | | | |
| // this is called when the connection attempt has succeeded | | // this is called when the connection attempt has succeeded | |
| // and the peer_connection is supposed to set m_connecting | | // and the peer_connection is supposed to set m_connecting | |
| // to false, and stop monitor writability | | // to false, and stop monitor writability | |
| void on_connection_complete(error_code const& e); | | void on_connection_complete(error_code const& e); | |
| | | | |
| // returns true if this connection is still waiting to | | // returns true if this connection is still waiting to | |
| // finish the connection attempt | | // finish the connection attempt | |
| bool is_connecting() const { return m_connecting; } | | bool is_connecting() const { return m_connecting; } | |
| | | | |
| skipping to change at line 502 | | skipping to change at line 502 | |
| if (m_ses.m_disk_thread.is_disk_buffer(buffer)) | | if (m_ses.m_disk_thread.is_disk_buffer(buffer)) | |
| m_ses.m_disk_thread.rename_buffer(buffer, "q
ueued send buffer"); | | m_ses.m_disk_thread.rename_buffer(buffer, "q
ueued send buffer"); | |
| #endif | | #endif | |
| m_send_buffer.append_buffer(buffer, size, size, dest
ructor); | | m_send_buffer.append_buffer(buffer, size, size, dest
ructor); | |
| #if defined TORRENT_STATS && defined TORRENT_DISK_STATS | | #if defined TORRENT_STATS && defined TORRENT_DISK_STATS | |
| m_ses.m_buffer_usage_logger << log_time() << " appen
d_send_buffer: " << size << std::endl; | | m_ses.m_buffer_usage_logger << log_time() << " appen
d_send_buffer: " << size << std::endl; | |
| m_ses.log_buffer_usage(); | | m_ses.log_buffer_usage(); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
|
| | | virtual void append_const_send_buffer(char const* buffer, in | |
| | | t size); | |
| | | | |
| #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES | | #ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES | |
| void set_country(char const* c) | | void set_country(char const* c) | |
| { | | { | |
| TORRENT_ASSERT(strlen(c) == 2); | | TORRENT_ASSERT(strlen(c) == 2); | |
| m_country[0] = c[0]; | | m_country[0] = c[0]; | |
| m_country[1] = c[1]; | | m_country[1] = c[1]; | |
| } | | } | |
| bool has_country() const { return m_country[0] != 0; } | | bool has_country() const { return m_country[0] != 0; } | |
| #endif | | #endif | |
| | | | |
| | | | |
| skipping to change at line 541 | | skipping to change at line 543 | |
| 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(); | | void setup_receive(); | |
| | | | |
| protected: | | protected: | |
| | | | |
|
| | | enum sync_t { read_async, read_sync }; | |
| | | 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; | |
| virtual void write_have(int index) = 0; | | virtual void write_have(int index) = 0; | |
| virtual void write_keepalive() = 0; | | virtual void write_keepalive() = 0; | |
| | | | |
| skipping to change at line 617 | | skipping to change at line 622 | |
| // a back reference to the session | | // a back reference to the session | |
| // the peer belongs to. | | // the peer belongs to. | |
| aux::session_impl& m_ses; | | aux::session_impl& m_ses; | |
| | | | |
| // called from the main loop when this connection has any | | // called from the main loop when this connection has any | |
| // work to do. | | // work to do. | |
| void on_send_data(error_code const& error | | void on_send_data(error_code const& error | |
| , std::size_t bytes_transferred); | | , std::size_t bytes_transferred); | |
| void on_receive_data(error_code const& error | | void on_receive_data(error_code const& error | |
| , std::size_t bytes_transferred); | | , std::size_t bytes_transferred); | |
|
| | | void on_receive_data_nolock(error_code const& error | |
| | | , std::size_t bytes_transferred); | |
| | | | |
| // this is the limit on the number of outstanding requests | | // this is the limit on the number of outstanding requests | |
| // we have to this peer. This is initialized to the settings | | // we have to this peer. This is initialized to the settings | |
| // in the session_settings structure. But it may be lowered | | // in the session_settings structure. But it may be lowered | |
| // if the peer is known to require a smaller limit (like Bit
Comet). | | // if the peer is known to require a smaller limit (like Bit
Comet). | |
| // or if the extended handshake sets a limit. | | // or if the extended handshake sets a limit. | |
| // web seeds also has a limit on the queue size. | | // web seeds also has a limit on the queue size. | |
| int m_max_out_request_queue; | | int m_max_out_request_queue; | |
| | | | |
| void set_timeout(int s) { m_timeout = s; } | | void set_timeout(int s) { m_timeout = s; } | |
| | | | |
End of changes. 4 change blocks. |
| 1 lines changed or deleted | | 9 lines changed or added | |
|
| piece_picker.hpp | | piece_picker.hpp | |
| | | | |
| skipping to change at line 279 | | skipping to change at line 279 | |
| // or if it already has been successfully downloaded | | // or if it already has been successfully downloaded | |
| bool is_requested(piece_block block) const; | | bool is_requested(piece_block block) const; | |
| // returns true if the block has been downloaded | | // returns true if the block has been downloaded | |
| bool is_downloaded(piece_block block) const; | | bool is_downloaded(piece_block block) const; | |
| // returns true if the block has been downloaded and written
to disk | | // returns true if the block has been downloaded and written
to disk | |
| bool is_finished(piece_block block) const; | | bool is_finished(piece_block block) const; | |
| | | | |
| // marks this piece-block as queued for downloading | | // marks this piece-block as queued for downloading | |
| bool mark_as_downloading(piece_block block, void* peer | | bool mark_as_downloading(piece_block block, void* peer | |
| , piece_state_t s); | | , piece_state_t s); | |
|
| void mark_as_writing(piece_block block, void* peer); | | // returns true if the block was marked as writing, | |
| | | // and false if the block is already finished or writing | |
| | | bool mark_as_writing(piece_block block, void* peer); | |
| | | | |
| void mark_as_finished(piece_block block, void* peer); | | void mark_as_finished(piece_block block, void* peer); | |
| void write_failed(piece_block block); | | void write_failed(piece_block block); | |
| int num_peers(piece_block block) const; | | int num_peers(piece_block block) const; | |
| ptime last_request(int piece) const; | | ptime last_request(int piece) const; | |
| | | | |
| // returns information about the given piece | | // returns information about the given piece | |
| void piece_info(int index, piece_picker::downloading_piece&
st) const; | | void piece_info(int index, piece_picker::downloading_piece&
st) const; | |
| | | | |
| // if a piece had a hash-failure, it must be restored and | | // if a piece had a hash-failure, it must be restored and | |
| // made available for redownloading | | // made available for redownloading | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 4 lines changed or added | |
|
| session_settings.hpp | | session_settings.hpp | |
| | | | |
| skipping to change at line 187 | | skipping to change at line 187 | |
| , optimistic_disk_retry(10 * 60) | | , optimistic_disk_retry(10 * 60) | |
| , disable_hash_checks(false) | | , disable_hash_checks(false) | |
| , allow_reordered_disk_operations(true) | | , allow_reordered_disk_operations(true) | |
| , max_suggest_pieces(10) | | , max_suggest_pieces(10) | |
| , drop_skipped_requests(false) | | , drop_skipped_requests(false) | |
| , low_prio_disk(true) | | , low_prio_disk(true) | |
| , local_service_announce_interval(5 * 60) | | , local_service_announce_interval(5 * 60) | |
| , udp_tracker_token_expiry(60) | | , udp_tracker_token_expiry(60) | |
| , report_true_downloaded(false) | | , report_true_downloaded(false) | |
| , strict_end_game_mode(true) | | , strict_end_game_mode(true) | |
|
| | | , broadcast_lsd(false) | |
| {} | | {} | |
| | | | |
| // 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 680 | | skipping to change at line 681 | |
| | | | |
| // when set to true, the downloaded counter sent to trackers | | // when set to true, the downloaded counter sent to trackers | |
| // will include the actual number of payload bytes donwnload
ed | | // will include the actual number of payload bytes donwnload
ed | |
| // including redundant bytes. If set to false, it will not i
nclude | | // including redundant bytes. If set to false, it will not i
nclude | |
| // any redundany bytes | | // any redundany bytes | |
| bool report_true_downloaded; | | bool report_true_downloaded; | |
| | | | |
| // if set to true, libtorrent won't request a piece multiple
times | | // if set to true, libtorrent won't request a piece multiple
times | |
| // until every piece is requested | | // until every piece is requested | |
| bool strict_end_game_mode; | | bool strict_end_game_mode; | |
|
| | | | |
| | | // if this is true, the broadcast socket will not only use I | |
| | | P multicast | |
| | | // but also send the messages on the broadcast address. This | |
| | | is false by | |
| | | // default in order to avoid flooding networks for no good r | |
| | | eason. If | |
| | | // a network is known not to support multicast, this can be | |
| | | enabled | |
| | | bool broadcast_lsd; | |
| }; | | }; | |
| | | | |
| #ifndef TORRENT_DISABLE_DHT | | #ifndef TORRENT_DISABLE_DHT | |
| struct dht_settings | | struct dht_settings | |
| { | | { | |
| dht_settings() | | dht_settings() | |
| : max_peers_reply(100) | | : max_peers_reply(100) | |
| , 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 | | 11 lines changed or added | |
|