forked from premiere/premiere-libtorrent
made the invariant checks cheaper and more useful. The full invariant checks are still available as an option
This commit is contained in:
parent
ff6cbbc6b6
commit
1ed583011c
3
Jamfile
3
Jamfile
|
@ -203,8 +203,9 @@ feature.compose <geoip>off : <define>TORRENT_DISABLE_GEO_IP ;
|
|||
feature bandwidth-limit-logging : off on : composite propagated link-incompatible ;
|
||||
feature.compose <bandwidth-limit-logging>on : <define>TORRENT_VERBOSE_BANDWIDTH_LIMIT ;
|
||||
|
||||
feature invariant-checks : on off : composite propagated link-incompatible ;
|
||||
feature invariant-checks : on off full : composite propagated link-incompatible ;
|
||||
feature.compose <invariant-checks>off : <define>TORRENT_DISABLE_INVARIANT_CHECKS ;
|
||||
feature.compose <invariant-checks>full : <define>TORRENT_EXPENSIVE_INVARIANT_CHECKS ;
|
||||
|
||||
feature disk-stats : off on : composite propagated link-incompatible ;
|
||||
feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
|
||||
|
|
|
@ -315,6 +315,8 @@ Build features:
|
|||
| | * ``off`` - internal invariant checks are |
|
||||
| | disabled. The resulting executable will run |
|
||||
| | faster than a regular debug build. |
|
||||
| | * ``full`` - turns on extra expensive invariant |
|
||||
| | checks. |
|
||||
+------------------------+----------------------------------------------------+
|
||||
| ``debug-symbols`` | * ``on`` - default for debug builds. This setting |
|
||||
| | is useful for building release builds with |
|
||||
|
@ -493,109 +495,113 @@ invariant checks and asserts built into it. If you want to disable such checks
|
|||
(you want to do that in a release build) you can see the table below for which
|
||||
defines you can use to control the build.
|
||||
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| macro | description |
|
||||
+=======================================+=================================================+
|
||||
| ``NDEBUG`` | If you define this macro, all asserts, |
|
||||
| | invariant checks and general debug code will be |
|
||||
| | removed. Since there is quite a lot of code in |
|
||||
| | in header files in libtorrent, it may be |
|
||||
| | important to define the symbol consistently |
|
||||
| | across compilation units, including the clients |
|
||||
| | files. Potential problems is different |
|
||||
| | compilation units having different views of |
|
||||
| | structs and class layouts and sizes. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_LOGGING`` | This macro will enable logging of the session |
|
||||
| | events, such as tracker announces and incoming |
|
||||
| | connections (as well as blocked connections). |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_GEO_IP`` | This is defined by default by the Jamfile. It |
|
||||
| | disables the GeoIP features, and avoids linking |
|
||||
| | against LGPL:ed code. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_VERBOSE_LOGGING`` | If you define this macro, every peer connection |
|
||||
| | will log its traffic to a log file as well as |
|
||||
| | the session log. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_STORAGE_DEBUG`` | This will enable extra expensive invariant |
|
||||
| | checks in the storage, including logging of |
|
||||
| | piece sorting. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_UPNP_LOGGING`` | Generates a "upnp.log" file with the UPnP |
|
||||
| | traffic. This is very useful when debugging |
|
||||
| | support for various UPnP routers. |
|
||||
| | support for various UPnP routers. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISK_STATS`` | This will create a log of all disk activity |
|
||||
| | which later can parsed and graphed using |
|
||||
| | ``parse_disk_log.py``. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_STATS`` | This will generate a log with transfer rates, |
|
||||
| | downloading torrents, seeding torrents, peers, |
|
||||
| | connecting peers and disk buffers in use. The |
|
||||
| | log can be parsed and graphed with |
|
||||
| | ``parse_session_stats.py``. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``UNICODE`` | If building on windows this will make sure the |
|
||||
| | UTF-8 strings in pathnames are converted into |
|
||||
| | UTF-16 before they are passed to the file |
|
||||
| | operations. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``LITTLE_ENDIAN`` | This will use the little endian version of the |
|
||||
| | sha-1 code. If defined on a big-endian system |
|
||||
| | the sha-1 hashes will be incorrect and fail. |
|
||||
| | If it is not defined and ``__BIG_ENDIAN__`` |
|
||||
| | isn't defined either (it is defined by Apple's |
|
||||
| | GCC) both little-endian and big-endian versions |
|
||||
| | will be built and the correct code will be |
|
||||
| | chosen at run-time. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_POOL_ALLOCATOR`` | Disables use of ``boost::pool<>``. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_LINKING_SHARED`` | If this is defined when including the |
|
||||
| | libtorrent headers, the classes and functions |
|
||||
| | will be tagged with ``__declspec(dllimport)`` |
|
||||
| | on msvc and default visibility on GCC 4 and |
|
||||
| | later. Set this in your project if you're |
|
||||
| | linking against libtorrent as a shared library. |
|
||||
| | (This is set by the Jamfile when |
|
||||
| | ``link=shared`` is set). |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_BUILDING_SHARED`` | If this is defined, the functions and classes |
|
||||
| | in libtorrent are marked with |
|
||||
| | ``__declspec(dllexport)`` on msvc, or with |
|
||||
| | default visibility on GCC 4 and later. This |
|
||||
| | should be defined when building libtorrent as |
|
||||
| | a shared library. (This is set by the Jamfile |
|
||||
| | when ``link=shared`` is set). |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_DHT`` | If this is defined, the support for trackerless |
|
||||
| | torrents will be disabled. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DHT_VERBOSE_LOGGING`` | This will enable verbose logging of the DHT |
|
||||
| | protocol traffic. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_ENCRYPTION`` | This will disable any encryption support and |
|
||||
| | the openssl dependency that comes with it. |
|
||||
| | Encryption support is the peer connection |
|
||||
| | encrypted supported by clients such as |
|
||||
| | uTorrent, Azureus and KTorrent. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``_UNICODE`` | On windows, this will cause the file IO |
|
||||
| | use wide character API, to properly support |
|
||||
| | non-ansi characters. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_RESOLVE_COUNTRIES`` | Defining this will disable the ability to |
|
||||
| | resolve countries of origin for peer IPs. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_INVARIANT_CHECKS`` | This will disable internal invariant checks in |
|
||||
| | libtorrent. The invariant checks can sometime |
|
||||
| | be quite expensive, they typically don't scale |
|
||||
| | very well. This option can be used to still |
|
||||
| | build in debug mode, with asserts enabled, but |
|
||||
| | make the resulting executable faster. |
|
||||
+---------------------------------------+-------------------------------------------------+
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| macro | description |
|
||||
+========================================+=================================================+
|
||||
| ``NDEBUG`` | If you define this macro, all asserts, |
|
||||
| | invariant checks and general debug code will be |
|
||||
| | removed. Since there is quite a lot of code in |
|
||||
| | in header files in libtorrent, it may be |
|
||||
| | important to define the symbol consistently |
|
||||
| | across compilation units, including the clients |
|
||||
| | files. Potential problems is different |
|
||||
| | compilation units having different views of |
|
||||
| | structs and class layouts and sizes. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_LOGGING`` | This macro will enable logging of the session |
|
||||
| | events, such as tracker announces and incoming |
|
||||
| | connections (as well as blocked connections). |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_GEO_IP`` | This is defined by default by the Jamfile. It |
|
||||
| | disables the GeoIP features, and avoids linking |
|
||||
| | against LGPL:ed code. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_VERBOSE_LOGGING`` | If you define this macro, every peer connection |
|
||||
| | will log its traffic to a log file as well as |
|
||||
| | the session log. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_STORAGE_DEBUG`` | This will enable extra expensive invariant |
|
||||
| | checks in the storage, including logging of |
|
||||
| | piece sorting. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_UPNP_LOGGING`` | Generates a "upnp.log" file with the UPnP |
|
||||
| | traffic. This is very useful when debugging |
|
||||
| | support for various UPnP routers. |
|
||||
| | support for various UPnP routers. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISK_STATS`` | This will create a log of all disk activity |
|
||||
| | which later can parsed and graphed using |
|
||||
| | ``parse_disk_log.py``. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_STATS`` | This will generate a log with transfer rates, |
|
||||
| | downloading torrents, seeding torrents, peers, |
|
||||
| | connecting peers and disk buffers in use. The |
|
||||
| | log can be parsed and graphed with |
|
||||
| | ``parse_session_stats.py``. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``UNICODE`` | If building on windows this will make sure the |
|
||||
| | UTF-8 strings in pathnames are converted into |
|
||||
| | UTF-16 before they are passed to the file |
|
||||
| | operations. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``LITTLE_ENDIAN`` | This will use the little endian version of the |
|
||||
| | sha-1 code. If defined on a big-endian system |
|
||||
| | the sha-1 hashes will be incorrect and fail. |
|
||||
| | If it is not defined and ``__BIG_ENDIAN__`` |
|
||||
| | isn't defined either (it is defined by Apple's |
|
||||
| | GCC) both little-endian and big-endian versions |
|
||||
| | will be built and the correct code will be |
|
||||
| | chosen at run-time. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_POOL_ALLOCATOR`` | Disables use of ``boost::pool<>``. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_LINKING_SHARED`` | If this is defined when including the |
|
||||
| | libtorrent headers, the classes and functions |
|
||||
| | will be tagged with ``__declspec(dllimport)`` |
|
||||
| | on msvc and default visibility on GCC 4 and |
|
||||
| | later. Set this in your project if you're |
|
||||
| | linking against libtorrent as a shared library. |
|
||||
| | (This is set by the Jamfile when |
|
||||
| | ``link=shared`` is set). |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_BUILDING_SHARED`` | If this is defined, the functions and classes |
|
||||
| | in libtorrent are marked with |
|
||||
| | ``__declspec(dllexport)`` on msvc, or with |
|
||||
| | default visibility on GCC 4 and later. This |
|
||||
| | should be defined when building libtorrent as |
|
||||
| | a shared library. (This is set by the Jamfile |
|
||||
| | when ``link=shared`` is set). |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_DHT`` | If this is defined, the support for trackerless |
|
||||
| | torrents will be disabled. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DHT_VERBOSE_LOGGING`` | This will enable verbose logging of the DHT |
|
||||
| | protocol traffic. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_ENCRYPTION`` | This will disable any encryption support and |
|
||||
| | the openssl dependency that comes with it. |
|
||||
| | Encryption support is the peer connection |
|
||||
| | encrypted supported by clients such as |
|
||||
| | uTorrent, Azureus and KTorrent. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``_UNICODE`` | On windows, this will cause the file IO |
|
||||
| | use wide character API, to properly support |
|
||||
| | non-ansi characters. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_RESOLVE_COUNTRIES`` | Defining this will disable the ability to |
|
||||
| | resolve countries of origin for peer IPs. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_DISABLE_INVARIANT_CHECKS`` | This will disable internal invariant checks in |
|
||||
| | libtorrent. The invariant checks can sometime |
|
||||
| | be quite expensive, they typically don't scale |
|
||||
| | very well. This option can be used to still |
|
||||
| | build in debug mode, with asserts enabled, but |
|
||||
| | make the resulting executable faster. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
| ``TORRENT_EXPENSIVE_INVARIANT_CHECKS`` | This will enable extra expensive invariant |
|
||||
| | checks. Useful for finding particular bugs |
|
||||
| | or for running before releases. |
|
||||
+----------------------------------------+-------------------------------------------------+
|
||||
|
||||
|
||||
If you experience that libtorrent uses unreasonable amounts of cpu, it will
|
||||
|
|
|
@ -3586,9 +3586,6 @@ namespace libtorrent
|
|||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
if (m_disconnecting)
|
||||
{
|
||||
for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin()
|
||||
, end(m_ses.m_torrents.end()); i != end; ++i)
|
||||
TORRENT_ASSERT(!i->second->has_peer((peer_connection*)this));
|
||||
TORRENT_ASSERT(!t);
|
||||
}
|
||||
else if (!m_in_constructor)
|
||||
|
@ -3629,11 +3626,13 @@ namespace libtorrent
|
|||
|
||||
if (!t)
|
||||
{
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
// since this connection doesn't have a torrent reference
|
||||
// no torrent should have a reference to this connection either
|
||||
for (aux::session_impl::torrent_map::const_iterator i = m_ses.m_torrents.begin()
|
||||
, end(m_ses.m_torrents.end()); i != end; ++i)
|
||||
TORRENT_ASSERT(!i->second->has_peer((peer_connection*)this));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3643,7 +3642,9 @@ namespace libtorrent
|
|||
for (torrent::const_peer_iterator i = t->begin(); i != t->end(); ++i)
|
||||
{
|
||||
// make sure this peer is not a dangling pointer
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
TORRENT_ASSERT(m_ses.has_peer(*i));
|
||||
#endif
|
||||
peer_connection const& p = *(*i);
|
||||
for (std::deque<piece_block>::const_iterator i = p.request_queue().begin()
|
||||
, end(p.request_queue().end()); i != end; ++i)
|
||||
|
@ -3659,16 +3660,18 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(t->picker().num_peers(i->first) == i->second);
|
||||
}
|
||||
}
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
if (m_peer_info)
|
||||
{
|
||||
policy::const_iterator i;
|
||||
for (i = t->get_policy().begin_peer();
|
||||
i != t->get_policy().end_peer(); ++i)
|
||||
for (i = t->get_policy().begin_peer()
|
||||
, end(t->get_policy().end_peer()); i != end; ++i)
|
||||
{
|
||||
if (&i->second == m_peer_info) break;
|
||||
}
|
||||
TORRENT_ASSERT(i != t->get_policy().end_peer());
|
||||
}
|
||||
#endif
|
||||
if (t->has_picker() && !t->is_aborted())
|
||||
{
|
||||
// make sure that pieces that have completed the download
|
||||
|
|
|
@ -3351,8 +3351,10 @@ namespace libtorrent
|
|||
std::map<piece_block, int> num_requests;
|
||||
for (const_peer_iterator i = begin(); i != end(); ++i)
|
||||
{
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
// make sure this peer is not a dangling pointer
|
||||
TORRENT_ASSERT(m_ses.has_peer(*i));
|
||||
#endif
|
||||
peer_connection const& p = *(*i);
|
||||
for (std::deque<piece_block>::const_iterator i = p.request_queue().begin()
|
||||
, end(p.request_queue().end()); i != end; ++i)
|
||||
|
@ -3387,11 +3389,13 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_abort || m_picker->num_pieces() == 0);
|
||||
}
|
||||
|
||||
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
|
||||
for (policy::const_iterator i = m_policy.begin_peer()
|
||||
, end(m_policy.end_peer()); i != end; ++i)
|
||||
{
|
||||
TORRENT_ASSERT(i->second.ip.address() == i->first);
|
||||
}
|
||||
#endif
|
||||
|
||||
size_type total_done = quantized_bytes_done();
|
||||
if (m_torrent_file->is_valid())
|
||||
|
|
Loading…
Reference in New Issue