From 00df2b5bc3bb6cb1140639268a6fc702fe471077 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 26 Jul 2006 10:21:25 +0000 Subject: [PATCH] added build notes for vs.net 2005, removed old code from ip_filter.cpp, fixed problem where the stats could become incorrect in case of very high cpu load, added asserts in storage::read() to make sure one is not trying to read out of bounds. --- ChangeLog | 4 + docs/client_test.html | 6 +- docs/extension_protocol.html | 14 ++-- docs/index.html | 136 ++------------------------------- docs/manual.html | 3 +- docs/manual.rst | 5 +- docs/udp_tracker_protocol.html | 38 ++++----- docs/vs2005_build_notes.html | 117 ++++++++++++++++++++++++++++ docs/vs2005_build_notes.rst | 92 ++++++++++++++++++++++ examples/client_test.cpp | 1 + include/libtorrent/session.hpp | 4 +- src/ip_filter.cpp | 17 ----- src/peer_connection.cpp | 3 + src/policy.cpp | 1 - src/session.cpp | 2 +- src/storage.cpp | 1 + src/torrent.cpp | 5 +- src/torrent_info.cpp | 1 + 18 files changed, 267 insertions(+), 183 deletions(-) create mode 100644 docs/vs2005_build_notes.html create mode 100644 docs/vs2005_build_notes.rst diff --git a/ChangeLog b/ChangeLog index 4d4631f80..6449e064b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ + + * Added more clients to the identifiable list + * Fixed fingerprint parser to cope with latest Mainline versions + release 0.10 * fixed a bug where the requested number of peers in a tracker request could diff --git a/docs/client_test.html b/docs/client_test.html index e26133af3..5e23661a0 100644 --- a/docs/client_test.html +++ b/docs/client_test.html @@ -3,7 +3,7 @@ - + client_test example program @@ -26,7 +26,7 @@ client and has the metadata (.torrent file). The metadata extension in libtorrent will then download it from that peer (or from those peers if more than one).

While running, the client_test sample will look something like this:

-client_test.png +
client_test.png

The commands available in the client are:

-
-

+ -
-

Feedback

+
+

Feedback

There's a mailing list, general libtorrent discussion.

You can usually find me as hydri in #libtorrent on irc.freenode.net.

-
-

Acknowledgements

+
+

Acknowledgements

Written by Arvid Norberg. Copyright (c) 2003

Contributions by Magnus Jonsson, Daniel Wallin and Cory Nelson

Thanks to Reimond Retz for bugfixes, suggestions and testing

diff --git a/docs/manual.html b/docs/manual.html index eac2c257a..9490349b2 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -504,7 +504,8 @@ filenames, so if your target is Windows 2000 and up, you may want to use file_win.cpp which supports unicode filenames.

If you're building in MS Visual Studio, you may have to set the compiler options "force conformance in for loop scope", "treat wchar_t as built-in -type" and "Enable Run-Time Type Info" to Yes.

+type" and "Enable Run-Time Type Info" to Yes. For a detailed description +on how to build libtorrent with VS 2005, see this document.

build configurations

diff --git a/docs/manual.rst b/docs/manual.rst index 77dee79f4..d57dabc0a 100755 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -410,7 +410,10 @@ filenames, so if your target is Windows 2000 and up, you may want to use If you're building in MS Visual Studio, you may have to set the compiler options "force conformance in for loop scope", "treat wchar_t as built-in -type" and "Enable Run-Time Type Info" to Yes. +type" and "Enable Run-Time Type Info" to Yes. For a detailed description +on how to build libtorrent with VS 2005, see `this document`_. + +.. _`this document`: vs2005_build_notes.html build configurations diff --git a/docs/udp_tracker_protocol.html b/docs/udp_tracker_protocol.html index 0098bd9ad..b01a8fa92 100644 --- a/docs/udp_tracker_protocol.html +++ b/docs/udp_tracker_protocol.html @@ -3,7 +3,7 @@ - + Bittorrent udp-tracker protocol extension @@ -35,8 +35,8 @@
  • credits
  • -
    -

    introduction

    +
    +

    introduction

    A tracker with the protocol "udp://" in its URI is supposed to be contacted using this protocol.

    This protocol is supported by @@ -50,8 +50,8 @@ are specified with ANSI-C standard types.

    the request. If no reply has been received after 60 seconds, stop retrying.

    -
    -

    connecting

    +
    +

    connecting

    Client sends packet:

    @@ -120,8 +120,8 @@ anymore.
    -
    -

    announcing

    +
    +

    announcing

    Client sends packet:

    @@ -282,8 +282,8 @@ seeding.
    -
    -

    scraping

    +
    +

    scraping

    Client sends packet:

    @@ -401,8 +401,8 @@ leechers.
    -
    -

    errors

    +
    +

    errors

    In case of a tracker error,

    server replies packet:

    @@ -436,8 +436,8 @@ describing the error.
    -
    -

    actions

    +
    +

    actions

    The action fields has the following encoding:

      @@ -448,8 +448,8 @@ describing the error.
    -
    -

    extensions

    +
    +

    extensions

    The extensions field is a bitmask. The following bits are assigned:

    @@ -457,8 +457,8 @@ bits are assigned:

  • 1 = authentication.
  • -
    -

    authentication

    +
    +

    authentication

    The packet will have an authentication part appended to it. It has the following format:

    @@ -497,8 +497,8 @@ from the 20 bytes hash calculated.
    -
    -

    credits

    +
    +

    credits

    Protocol designed by Olaf van der Spek

    diff --git a/docs/vs2005_build_notes.html b/docs/vs2005_build_notes.html new file mode 100644 index 000000000..a2f51aa52 --- /dev/null +++ b/docs/vs2005_build_notes.html @@ -0,0 +1,117 @@ + + + + + + +libtorrent setup for VS.NET 2005 Development + + + + +
    +

    libtorrent setup for VS.NET 2005 Development

    + +++ + + + + + +
    Author:THOMAS GODDARD
    Contact:www.thomasgoddard.com
    +
    +

    Prerequisites

    +
      +
    1. Download boost from boost.org
    2. +
    3. Download libtorrent
    4. +
    5. Extract both to a folder called libtorrent
    6. +
    +
    +
    +

    Compiling boost for VS.NET 2005

    +
      +
    1. Copy bjam.exe to libtorrent\boost_[version]\tools\build
    2. +
    3. Add the path "libtorrent\boost_[version]\tools\build" to the windows path environment variable
    4. +
    5. Log off / log back on
    6. +
    7. Open the file "libtorrent\boost_[version]\tools\build\user-config.jam" in notepad
    8. +
    9. Uncomment the # using msvc; line by removing the #
    10. +
    11. Replace the line with: using vc-8_0 ;
    12. +
    13. Save the file and close it
    14. +
    15. Open the visual studio .net command line in the VS.net 2005 folder in your start menu
    16. +
    17. CD to the "libtorrent\boost_[version]" folder
    18. +
    19. Type: bjam "-sTOOLS=vc-8_0" install and hit enter
    20. +
    21. Be patient and wait for it to finish
    22. +
    +
    +

    Troubleshooting

    +
      +
    • Make sure to CD to the root of the boost directory before running the install.
    • +
    • For additional details and information on using Visual Studio 2005 Express addition, see the Boost Getting Started Guide.
    • +
    +
    +
    +
    +

    Setting up and compiling libtorrent with VS.NET 2005

    +
      +
    1. Create a new vs.net 2005 MFC project and solution file in the root of the libtorrent folder where you extracted all of the libtorrent files.

      +
    2. +
    3. Include the files contained in the src folder, excluding the makefiles. +NOTE: +Only include either file.cpp or file_win.cpp. Read here to determine which file to include: +http://www.rasterbar.com/products/libtorrent/docs.html#building-with-other-build-systems

      +
    4. +
    5. Include all .c files in the zlib folder.

      +
    6. +
    7. Add the following Additional Include Header Files:

      +
      +"libtorrent\include"
      +"C:\Boost\include\boost-1_33_1"
      +"libtorrent\zlib"
      +"libtorrent\include\libtorrent"
      +
      +
    8. +
    9. Add the following Preprocessor Definitions:

      +
      +WIN32
      +WIN32_LEAN_AND_MEAN
      +_WIN32_WINNT=0x0500
      +BOOST_ALL_NO_LIB
      +_FILE_OFFSET_BITS=64
      +BOOST_THREAD_USE_LIB
      +TORRENT_BUILDING_SHARED
      +TORRENT_LINKING_SHARED
      +UNICODE
      +
      +
    10. +
    11. Add C:\Boost\lib to Additional Library Directories

      +
    12. +
    13. Add the following Additional Dependencies:

      +
      +wsock32.lib
      +libboost_thread-vc80-mt.lib
      +libboost_filesystem-vc80-mt.lib
      +libboost_date_time-vc80-mt.lib
      +
      +
    14. +
    15. Set the Runtime Library to Multi-threaded Debug DLL (/MDd) under the code generation section.

      +
    16. +
    +
    +

    Troubleshooting

    +
    +
    Error: error LNK2005:already defined etc...
    +
    Make sure you use the Multi-threaded Debug DLL (/MDd)
    +
    Error: error linking zlib related files...
    +
    Make sure to include all .c files in the zlib folder.
    +
    Runtime error in client_test.exe
    +
    If you're using boost-1.33.1, there is a bug in the program options +library which will make VS.NET 2005 assert. For a patch, see: +http://thread.gmane.org/gmane.comp.lib.boost.devel/140932/focus=140932
    +
    +
    +
    +
    + + diff --git a/docs/vs2005_build_notes.rst b/docs/vs2005_build_notes.rst new file mode 100644 index 000000000..c4980e086 --- /dev/null +++ b/docs/vs2005_build_notes.rst @@ -0,0 +1,92 @@ +============================================ +libtorrent setup for VS.NET 2005 Development +============================================ + +:Author: THOMAS GODDARD +:Contact: www.thomasgoddard.com + +Prerequisites +------------- + +1. Download boost from boost.org +2. Download libtorrent +3. Extract both to a folder called libtorrent + +Compiling boost for VS.NET 2005 +------------------------------- + +1. Copy bjam.exe to libtorrent\\boost_[version]\\tools\\build +2. Add the path "libtorrent\\boost_[version]\\tools\\build" to the windows path environment variable +3. Log off / log back on +4. Open the file "libtorrent\\boost_[version]\\tools\\build\\user-config.jam" in notepad +5. Uncomment the ``# using msvc;`` line by removing the # +6. Replace the line with: ``using vc-8_0 ;`` +7. Save the file and close it +8. Open the visual studio .net command line in the VS.net 2005 folder in your start menu +9. CD to the "libtorrent\\boost_[version]" folder +10. Type: ``bjam "-sTOOLS=vc-8_0" install`` and hit enter +11. Be patient and wait for it to finish + +Troubleshooting +............... + +* Make sure to CD to the root of the boost directory before running the install. + +* For additional details and information on using Visual Studio 2005 Express addition, see the Boost Getting Started Guide. + +Setting up and compiling libtorrent with VS.NET 2005 +----------------------------------------------------- + +1. Create a new vs.net 2005 MFC project and solution file in the root of the libtorrent folder where you extracted all of the libtorrent files. +2. Include the files contained in the src folder, excluding the makefiles. + **NOTE:** + Only include either file.cpp or file_win.cpp. Read here to determine which file to include: + http://www.rasterbar.com/products/libtorrent/docs.html#building-with-other-build-systems + +3. Include all .c files in the zlib folder. + +4. Add the following Additional Include Header Files:: + + "libtorrent\include" + "C:\Boost\include\boost-1_33_1" + "libtorrent\zlib" + "libtorrent\include\libtorrent" + +5. Add the following Preprocessor Definitions:: + + WIN32 + WIN32_LEAN_AND_MEAN + _WIN32_WINNT=0x0500 + BOOST_ALL_NO_LIB + _FILE_OFFSET_BITS=64 + BOOST_THREAD_USE_LIB + TORRENT_BUILDING_SHARED + TORRENT_LINKING_SHARED + UNICODE + +6. Add ``C:\Boost\lib`` to Additional Library Directories + +7. Add the following Additional Dependencies:: + + wsock32.lib + libboost_thread-vc80-mt.lib + libboost_filesystem-vc80-mt.lib + libboost_date_time-vc80-mt.lib + +8. Set the Runtime Library to Multi-threaded Debug DLL (/MDd) under the code generation section. + + +Troubleshooting +............... + +Error: error LNK2005:already defined etc... + Make sure you use the Multi-threaded Debug DLL (/MDd) + +Error: error linking zlib related files... + Make sure to include all .c files in the zlib folder. + +Runtime error in client_test.exe + If you're using boost-1.33.1, there is a bug in the program options + library which will make VS.NET 2005 assert. For a patch, see: + http://thread.gmane.org/gmane.comp.lib.boost.devel/140932/focus=140932 + diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 0cc282994..57aac294a 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -512,6 +512,7 @@ int main(int ac, char* av[]) session_settings settings; settings.user_agent = "client_test " LIBTORRENT_VERSION; + settings.sequenced_download_threshold = 15; std::deque events; diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index e95255615..8c16d5e97 100755 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -71,6 +71,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/ip_filter.hpp" #include "libtorrent/config.hpp" #include "libtorrent/session_settings.hpp" +#include "libtorrent/version.hpp" #if !defined(NDEBUG) && defined(_MSC_VER) # include @@ -343,7 +344,8 @@ namespace libtorrent { public: - session(fingerprint const& print = fingerprint("LT", 0, 10, 0, 0)); + session(fingerprint const& print = fingerprint("LT" + , LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)); session( fingerprint const& print , std::pair listen_port_range diff --git a/src/ip_filter.cpp b/src/ip_filter.cpp index 21d840726..899a11097 100644 --- a/src/ip_filter.cpp +++ b/src/ip_filter.cpp @@ -60,14 +60,7 @@ namespace libtorrent assert(j != i); int first_access = i->access; -/* - std::cout << "flags: " << flags << "\n"; - std::cout << "first_access: " << first_access << "\n"; - std::cout << "i->start: " << i->start.as_string() << "\n"; - std::cout << "first: " << first.as_string() << "\n"; -*/ int last_access = prior(j)->access; -// std::cout << "last_access: " << last_access << "\n"; if (i->start != first && first_access != flags) { @@ -78,20 +71,11 @@ namespace libtorrent --i; first_access = i->access; } -/* - std::cout << "distance(i, j): " << std::distance(i, j) << "\n"; - std::cout << "size(): " << m_access_list.size() << "\n"; -*/ assert(!m_access_list.empty()); assert(i != m_access_list.end()); if (i != j) m_access_list.erase(next(i), j); -/* - std::cout << "size(): " << m_access_list.size() << "\n"; - std::cout << "last: " << last.as_string() << "\n"; - std::cout << "last.ip(): " << last.ip() << " " << 0xffffffff << "\n"; -*/ if (i->start == first) { // we can do this const-cast because we know that the new @@ -108,7 +92,6 @@ namespace libtorrent || (j == m_access_list.end() && last.to_ulong() != 0xffffffff)) { assert(j == m_access_list.end() || last.to_ulong() < j->start.to_ulong() - 1); -// std::cout << " -- last_access: " << last_access << "\n"; if (last_access != flags) j = m_access_list.insert(j, range(address(last.to_ulong() + 1), last_access)); } diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index cbb8d37d3..696da1171 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1453,6 +1453,9 @@ namespace libtorrent m_download_queue.clear(); m_request_queue.clear(); + // TODO: If we have a limited number of upload + // slots, choke this peer + m_assume_fifo = true; // this will trigger new picking of pieces diff --git a/src/policy.cpp b/src/policy.cpp index 31da5401d..f14a7c346 100755 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -93,7 +93,6 @@ namespace // the last argument is if we should prefer whole pieces // for this peer. If we're downloading one piece in 20 seconds // then use this mode. - // TODO: 20 seconds has to be customizable bool prefer_whole_pieces = c.statistics().download_payload_rate() * t.settings().whole_pieces_threshold > t.torrent_file().piece_length(); diff --git a/src/session.cpp b/src/session.cpp index 0ee1a41d7..62395252b 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -866,7 +866,7 @@ namespace libtorrent { namespace detail // don't pass in the tick_interval here, because // the stats have already been adjusted in // the peer's second tick. - m_stat.second_tick(1.f); + m_stat.second_tick(tick_interval); // distribute the maximum upload rate among the torrents diff --git a/src/storage.cpp b/src/storage.cpp index 1eb80cc41..e17fc5916 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -627,6 +627,7 @@ namespace libtorrent #endif size_type start = slot * (size_type)m_pimpl->info.piece_length() + offset; + assert(start + size <= m_pimpl->info.total_size()); // find the file iterator and file offset size_type file_offset = start; diff --git a/src/torrent.cpp b/src/torrent.cpp index 2f0f7eeac..f7efde16e 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1566,10 +1566,7 @@ namespace libtorrent m_dl_bandwidth_quota.max = resource_request::inf; accumulator += m_stat; - // don't pass the tick interval in here, because - // the stats have already been adjusted in the - // peer's stats. - m_stat.second_tick(1.f); + m_stat.second_tick(tick_interval); } void torrent::distribute_resources() diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index eb54ac5ea..af7f37cd9 100755 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -638,6 +638,7 @@ namespace libtorrent std::vector ret; size_type start = piece * (size_type)m_piece_length + offset; + assert(start + size <= m_total_size); // find the file iterator and file offset // TODO: make a vector that can map piece -> file index in O(1)