fixed debug assert on linux

This commit is contained in:
Arvid Norberg 2007-09-10 06:12:41 +00:00
parent ee5ce50502
commit 57a76f9db6
23 changed files with 54 additions and 40 deletions

View File

@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/peer_connection.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -30,9 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_ASSERT_HPP_INCLUDED
#define TORRENT_ASSERT_HPP_INCLUDED
#include <cassert>
#ifndef NDEBUG
@ -43,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
void assert_fail(const char* expr, int line, char const* file, char const* function);
#define assert(x) if (!(x)) assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__)
#define assert(x) if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__)
#endif
@ -53,5 +50,3 @@ void assert_fail(const char* expr, int line, char const* file, char const* funct
#endif
#endif
#endif

View File

@ -83,6 +83,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket_type.hpp"
#include "libtorrent/connection_queue.hpp"
#include "libtorrent/disk_io_thread.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -33,9 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_BANDWIDTH_MANAGER_HPP_INCLUDED
#define TORRENT_BANDWIDTH_MANAGER_HPP_INCLUDED
#include "libtorrent/socket.hpp"
#include "libtorrent/invariant_check.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/function.hpp>
@ -44,6 +41,10 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/thread/mutex.hpp>
#include <deque>
#include "libtorrent/socket.hpp"
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/assert.hpp"
using boost::weak_ptr;
using boost::shared_ptr;
using boost::intrusive_ptr;

View File

@ -79,6 +79,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/entry.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#if defined(_MSC_VER)
namespace std
{

View File

@ -34,8 +34,9 @@ POSSIBILITY OF SUCH DAMAGE.
//#define TORRENT_BUFFER_DEBUG
#include "libtorrent/invariant_check.hpp"
#include <memory>
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent {

View File

@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
#include "libtorrent/peer_id.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{
@ -91,3 +92,4 @@ namespace libtorrent
}
#endif // TORRENT_FINGERPRINT_HPP_INCLUDED

View File

@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/socket.hpp"
#include "libtorrent/http_tracker_connection.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -33,6 +33,9 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_IP_FILTER_HPP
#define TORRENT_IP_FILTER_HPP
#include <set>
#include <iostream>
#ifdef _MSC_VER
#pragma warning(push, 1)
#endif
@ -48,8 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/socket.hpp"
#include <set>
#include <iostream>
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/kademlia/node_entry.hpp>
#include <libtorrent/session_settings.hpp>
#include <libtorrent/size_type.hpp>
#include <libtorrent/assert.hpp>
namespace libtorrent { namespace dht
{

View File

@ -72,6 +72,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/policy.hpp"
#include "libtorrent/socket_type.hpp"
#include "libtorrent/intrusive_ptr_base.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -40,6 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/size_type.hpp"
#include "libtorrent/invariant_check.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -55,6 +55,7 @@ namespace libtorrent
|| _POSIX_MONOTONIC_CLOCK < 0)) || defined (TORRENT_USE_BOOST_DATE_TIME)
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include "libtorrent/assert.hpp"
namespace libtorrent
{
@ -85,6 +86,7 @@ namespace libtorrent
#include <asio/time_traits.hpp>
#include <boost/cstdint.hpp>
#include "libtorrent/assert.hpp"
namespace libtorrent
{
@ -170,6 +172,7 @@ namespace asio
#include <mach/mach_time.h>
#include <boost/cstdint.hpp>
#include "libtorrent/assert.hpp"
// high precision timer for darwin intel and ppc
@ -249,6 +252,7 @@ namespace libtorrent
#define WIN32_LEAN_AND_MEAN
#endif
#include <Windows.h>
#include "libtorrent/assert.hpp"
namespace libtorrent
{
@ -335,6 +339,7 @@ namespace libtorrent
#elif defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0
#include <time.h>
#include "libtorrent/assert.hpp"
namespace libtorrent
{
@ -385,4 +390,4 @@ namespace libtorrent
#endif
#endif

View File

@ -68,6 +68,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/bandwidth_manager.hpp"
#include "libtorrent/storage.hpp"
#include "libtorrent/hasher.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -58,6 +58,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/intrusive_ptr_base.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{
@ -321,8 +322,10 @@ namespace libtorrent
entry m_extra_info;
#ifndef NDEBUG
public:
// this is set to true when seed_free() is called
bool m_half_metadata;
private:
#endif
};

View File

@ -30,13 +30,15 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/socket.hpp"
#include "libtorrent/enum_net.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include <asio/ip/host_name.hpp>
#include <asio/ip/multicast.hpp>
#include <boost/bind.hpp>
#include "libtorrent/socket.hpp"
#include "libtorrent/enum_net.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{
bool is_local(address const& a)

View File

@ -31,7 +31,6 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/pch.hpp"
#include "libtorrent/assert.hpp"
#include <string>
#include <stdexcept>
@ -40,6 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cctype>
#include <algorithm>
#include "libtorrent/assert.hpp"
namespace libtorrent
{
std::string unescape_string(std::string const& s)

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/kademlia/closest_nodes.hpp>
#include <libtorrent/kademlia/routing_table.hpp>
#include <libtorrent/kademlia/rpc_manager.hpp>
#include "libtorrent/assert.hpp"
namespace libtorrent { namespace dht
{

View File

@ -32,11 +32,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/pch.hpp"
#include <libtorrent/natpmp.hpp>
#include <libtorrent/io.hpp>
#include <boost/bind.hpp>
#include <asio/ip/host_name.hpp>
#include "libtorrent/natpmp.hpp"
#include "libtorrent/io.hpp"
#include "libtorrent/assert.hpp"
using boost::bind;
using namespace libtorrent;

View File

@ -182,6 +182,7 @@ namespace libtorrent
, bool paused
, storage_constructor_type sc)
{
assert(!ti.m_half_metadata);
boost::intrusive_ptr<torrent_info> tip(new torrent_info(ti));
return m_impl->add_torrent(tip, save_path, resume_data
, compact_mode, sc, paused);
@ -195,6 +196,7 @@ namespace libtorrent
, bool paused
, storage_constructor_type sc)
{
assert(!ti->m_half_metadata);
return m_impl->add_torrent(ti, save_path, resume_data
, compact_mode, sc, paused);
}

View File

@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/pch.hpp"
#include "libtorrent/socks5_stream.hpp"
#include "libtorrent/assert.hpp"
namespace libtorrent
{

View File

@ -72,6 +72,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/extensions.hpp"
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/instantiate_connection.hpp"
#include "libtorrent/assert.hpp"
using namespace libtorrent;
using boost::tuples::tuple;
@ -203,9 +204,6 @@ namespace libtorrent
, m_num_uploads(0)
, m_max_connections((std::numeric_limits<int>::max)())
{
#ifndef NDEBUG
m_initial_done = 0;
#endif
m_policy.reset(new policy(this));
}
@ -266,10 +264,6 @@ namespace libtorrent
, m_num_uploads(0)
, m_max_connections((std::numeric_limits<int>::max)())
{
#ifndef NDEBUG
m_initial_done = 0;
#endif
INVARIANT_CHECK;
if (name) m_name.reset(new std::string(name));
@ -2215,14 +2209,12 @@ namespace libtorrent
}
pause();
}
#ifndef NDEBUG
m_initial_done = boost::get<0>(bytes_done());
#endif
return done;
}
std::pair<bool, float> torrent::check_files()
{
assert(m_torrent_file->is_valid());
INVARIANT_CHECK;
assert(m_owning_storage.get());
@ -2250,9 +2242,6 @@ namespace libtorrent
pause();
}
#ifndef NDEBUG
m_initial_done = boost::get<0>(bytes_done());
#endif
return progress;
}
@ -2261,6 +2250,7 @@ namespace libtorrent
{
session_impl::mutex_t::scoped_lock l(m_ses.m_mutex);
assert(m_torrent_file->is_valid());
INVARIANT_CHECK;
if (!is_seed())
@ -2320,9 +2310,6 @@ namespace libtorrent
}
}
}
#ifndef NDEBUG
m_initial_done = boost::get<0>(bytes_done());
#endif
}
alert_manager& torrent::alerts() const
@ -2385,9 +2372,6 @@ namespace libtorrent
#ifndef NDEBUG
void torrent::check_invariant() const
{
// size_type download = m_stat.total_payload_download();
// size_type done = boost::get<0>(bytes_done());
// assert(download >= done - m_initial_done);
int num_uploads = 0;
std::map<piece_block, int> num_requests;
for (const_peer_iterator i = begin(); i != end(); ++i)

View File

@ -1,12 +1,15 @@
#include <fstream>
#include "libtorrent/session.hpp"
#include "libtorrent/hasher.hpp"
#include <fstream>
#include <boost/thread.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/convenience.hpp>
#include "test.hpp"
#include "libtorrent/assert.hpp"
using boost::filesystem::remove_all;
using boost::filesystem::create_directory;
@ -86,7 +89,7 @@ setup_transfer(session* ses1, session* ses2, session* ses3
// file pool will complain if two torrents are trying to
// use the same files
sha1_hash info_hash = t->info_hash();
torrent_handle tor1 = ses1->add_torrent(t, "./tmp1");
torrent_handle tor1 = ses1->add_torrent(clone_ptr(t), "./tmp1");
torrent_handle tor2;
torrent_handle tor3;
if (ses3) tor3 = ses3->add_torrent(clone_ptr(t), "./tmp3");