diff --git a/libtorrent/include/libtorrent/assert.hpp b/libtorrent/include/libtorrent/assert.hpp index 6943fadc2..6396526ba 100644 --- a/libtorrent/include/libtorrent/assert.hpp +++ b/libtorrent/include/libtorrent/assert.hpp @@ -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 diff --git a/libtorrent/include/libtorrent/create_torrent.hpp b/libtorrent/include/libtorrent/create_torrent.hpp index 32c7a41f2..e631a145a 100644 --- a/libtorrent/include/libtorrent/create_torrent.hpp +++ b/libtorrent/include/libtorrent/create_torrent.hpp @@ -78,10 +78,12 @@ namespace libtorrent void add_url_seed(std::string const& url); void add_node(std::pair 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: diff --git a/libtorrent/src/disk_io_thread.cpp b/libtorrent/src/disk_io_thread.cpp index f091c3db8..012658e59 100644 --- a/libtorrent/src/disk_io_thread.cpp +++ b/libtorrent/src/disk_io_thread.cpp @@ -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&) diff --git a/libtorrent/src/file.cpp b/libtorrent/src/file.cpp index 936e13ce4..29420711e 100755 --- a/libtorrent/src/file.cpp +++ b/libtorrent/src/file.cpp @@ -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) { diff --git a/libtorrent/src/peer_connection.cpp b/libtorrent/src/peer_connection.cpp index 95dd990b5..481361b6a 100755 --- a/libtorrent/src/peer_connection.cpp +++ b/libtorrent/src/peer_connection.cpp @@ -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()) diff --git a/libtorrent/src/piece_picker.cpp b/libtorrent/src/piece_picker.cpp index 9e62e6379..6adca41eb 100755 --- a/libtorrent/src/piece_picker.cpp +++ b/libtorrent/src/piece_picker.cpp @@ -222,6 +222,7 @@ namespace libtorrent } } +#ifdef TORRENT_PICKER_LOG void piece_picker::print_pieces() const { for (std::vector::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 { diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index d2e1b8064..66a0b0797 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -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);