lt sync 2583

This commit is contained in:
Andrew Resch 2008-07-30 09:55:58 +00:00
parent e1cc2d9e62
commit 221c0c31a4
7 changed files with 19 additions and 9 deletions

View File

@ -42,7 +42,7 @@ std::string demangle(char const* name);
#if (defined __linux__ || defined __MACH__) && defined __GNUC__ && !defined(NDEBUG)
TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file, char const* function);
#define TORRENT_ASSERT(x) if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__)
#define TORRENT_ASSERT(x) do { if (x) {} else assert_fail(#x, __LINE__, __FILE__, __PRETTY_FUNCTION__); } while (false)
#else
#include <cassert>

View File

@ -78,10 +78,12 @@ namespace libtorrent
void add_url_seed(std::string const& url);
void add_node(std::pair<std::string, int> const& node);
void add_tracker(std::string const& url, int tier = 0);
void set_priv(bool p) { m_private = p; }
int num_pieces() const { return m_files.num_pieces(); }
int piece_length() const { return m_files.piece_length(); }
int piece_size(int i) const { return m_files.piece_size(i); }
bool priv() const { return m_private; }
private:

View File

@ -1153,7 +1153,8 @@ namespace libtorrent
#ifndef BOOST_NO_EXCEPTIONS
try {
#endif
TORRENT_ASSERT(ret != -2 || !j.str.empty());
TORRENT_ASSERT(ret != -2 || !j.str.empty()
|| j.action == disk_io_job::hash);
if (handler) m_ios.post(bind(handler, ret, j));
#ifndef BOOST_NO_EXCEPTIONS
} catch (std::exception&)

View File

@ -201,8 +201,12 @@ namespace libtorrent
#else
// rely on default umask to filter x and w permissions
// for group and others
int permissions = S_IRUSR | S_IWUSR
| S_IRGRP | S_IWGRP
| S_IROTH | S_IWOTH;
m_fd = ::open(path.native_file_string().c_str()
, map_open_mode(mode.m_mask), S_IRWXU | S_IRWXG | S_IRWXO);
, map_open_mode(mode.m_mask), permissions);
if (m_fd == -1)
{

View File

@ -3710,13 +3710,13 @@ namespace libtorrent
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
if (m_peer_info)
{
policy::const_iterator i;
for (i = t->get_policy().begin_peer()
, end(t->get_policy().end_peer()); i != end; ++i)
policy::const_iterator i = t->get_policy().begin_peer();
policy::const_iterator end = t->get_policy().end_peer();
for (; i != end; ++i)
{
if (&i->second == m_peer_info) break;
}
TORRENT_ASSERT(i != t->get_policy().end_peer());
TORRENT_ASSERT(i != end);
}
#endif
if (t->has_picker() && !t->is_aborted())

View File

@ -222,6 +222,7 @@ namespace libtorrent
}
}
#ifdef TORRENT_PICKER_LOG
void piece_picker::print_pieces() const
{
for (std::vector<int>::const_iterator i = m_priority_boundries.begin()
@ -245,6 +246,7 @@ namespace libtorrent
}
std::cerr << std::endl;
}
#endif
void piece_picker::check_invariant(const torrent* t) const
{

View File

@ -3466,7 +3466,7 @@ namespace libtorrent
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);
TORRENT_ASSERT(i->second.addr == i->first);
}
#endif
@ -4144,7 +4144,6 @@ namespace libtorrent
TORRENT_ASSERT(valid_metadata());
fp.resize(m_torrent_file->num_files(), 0);
TORRENT_ASSERT(has_picker());
if (is_seed())
{
@ -4153,6 +4152,8 @@ namespace libtorrent
return;
}
TORRENT_ASSERT(has_picker());
for (int i = 0; i < m_torrent_file->num_files(); ++i)
{
peer_request ret = m_torrent_file->files().map_file(i, 0, 0);