From bfb0c4fe80c5b419f2e8f4690892a1f2648a1571 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 12 Nov 2014 16:57:59 +0000 Subject: [PATCH] merged changes from RC_1_0 --- build_dist.sh | 5 ++++- configure.ac | 26 ++++++++++++++++++++++---- include/libtorrent/torrent.hpp | 12 ++++++------ include/libtorrent/torrent_handle.hpp | 8 +++++--- src/torrent.cpp | 7 +++++++ src/torrent_handle.cpp | 5 +++-- test/Makefile.am | 1 + 7 files changed, 48 insertions(+), 16 deletions(-) diff --git a/build_dist.sh b/build_dist.sh index 3702216f6..da9fdd31e 100755 --- a/build_dist.sh +++ b/build_dist.sh @@ -22,6 +22,9 @@ rm -f bindings/python/Makefile bindings/python/Makefile.in chmod a-x docs/*.rst docs/*.htm* src/*.cpp include/libtorrent/*.hpp ./autotool.sh -./configure --enable-python-binding --enable-examples=yes --enable-encryption --enable-tests=yes --with-boost-system=mt --with-boost-chrono=mt --with-boost-random=mt --with-boost-python=mt --enable-tests +./configure --enable-python-binding --enable-examples=yes --enable-encryption --enable-tests=yes --with-boost-system=mt --with-boost-chrono=mt --with-boost-random=mt --with-boost-python=mt make V=1 -j8 check distcheck +./configure --enable-python-binding --enable-examples=yes --enable-encryption --with-boost-system=mt --with-boost-chrono=mt --with-boost-random=mt --with-boost-python=mt +make V=1 -j8 distcheck + diff --git a/configure.ac b/configure.ac index e47712251..3629d126b 100644 --- a/configure.ac +++ b/configure.ac @@ -110,9 +110,6 @@ AC_CACHE_CHECK([for __attribute__((visibility("hidden")))], then AS_ECHO "found" ac_cv_hidden_visibility_attribute=yes - CXXFLAGS="$CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden" - CFLAGS="$CFLAGS -fvisibility=hidden" - LDFLAGS="$LDFLAGS -fvisibility=hidden -fvisibility-inlines-hidden" fi rm -f visibility_conftest.* ]) @@ -232,6 +229,15 @@ AC_ARG_ENABLE( [[ARG_ENABLE_ENCRYPTION=yes]] ) +AC_ARG_ENABLE( + [export-all], + [AS_HELP_STRING( + [--enable-export-all], + [export all symbols from libtorrent, including non-public ones [default=no]])], + [[ARG_ENABLE_FULL_EXPORT=$enableval]], + [[ARG_ENABLE_FULL_EXPORT=no]] +) + AC_ARG_ENABLE( [pool-allocators], [AS_HELP_STRING( @@ -463,6 +469,14 @@ AS_CASE(["$ARG_ENABLE_POOL_ALLOC"], AC_MSG_ERROR([Unknown option "$ARG_ENABLE_POOL_ALLOC". Use either "yes" or "no".])] ) +AS_IF([test "x$ac_cv_hidden_visibility_attribute" = "xyes"], [ + AS_IF([test "x$ARG_ENABLE_FULL_EXPORT" = "xno"], [ + CXXFLAGS="$CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden" + CFLAGS="$CFLAGS -fvisibility=hidden" + LDFLAGS="$LDFLAGS -fvisibility=hidden -fvisibility-inlines-hidden" + ]) +]) + AS_ECHO AS_ECHO "Checking for extra build files:" @@ -476,7 +490,11 @@ AS_CASE(["$ARG_ENABLE_EXAMPLES"], AC_MSG_CHECKING([whether test files should be built]) AS_CASE(["$ARG_ENABLE_TESTS"], - ["yes"], [AC_MSG_RESULT([yes])], + ["yes"], [ + AC_MSG_RESULT([yes]) + AC_DEFINE([TORRENT_EXPORT_EXTRA],[1],[Define to export additional symbols for unit tests.]) + COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_EXPORT_EXTRA " + ], ["no"], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([$ARG_ENABLE_TESTS]) AC_MSG_ERROR([Unknown option "$ARG_ENABLE_TESTS". Use either "yes" or "no".])] diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index b1edabfe2..0e71a64b6 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -253,12 +253,8 @@ namespace libtorrent , sha1_hash const& info_hash); ~torrent(); - sha1_hash const& info_hash() const - { - TORRENT_ASSERT(m_torrent_file); - static sha1_hash empty; - return m_torrent_file ? m_torrent_file->info_hash() : empty; - } + // This may be called from multiple threads + sha1_hash const& info_hash() const { return m_info_hash; } bool is_deleted() const { return m_deleted; } @@ -1307,6 +1303,10 @@ namespace libtorrent // in this swarm time_t m_swarm_last_seen_complete; + // keep a copy if the info-hash here, so it can be accessed from multiple + // threads, and be cheap to access from the client + sha1_hash m_info_hash; + public: // these are the lists this torrent belongs to. For more // details about each list, see session_impl.hpp. Each list diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 2ac9e83b8..b66abbc5a 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -1212,11 +1212,13 @@ namespace libtorrent #endif // TORRENT_USE_WSTRING #endif // TORRENT_NO_DEPRECATE - // Enables or disabled super seeding/initial seeding for this torrent. The torrent - // needs to be a seed for this to take effect. + // Enables or disabled super seeding/initial seeding for this torrent. + // The torrent needs to be a seed for this to take effect. void super_seeding(bool on) const; - // ``info_hash()`` returns the info-hash for the torrent. + // ``info_hash()`` returns the info-hash of the torrent. If this handle + // is to a torrent that hasn't loaded yet (for instance by being added) + // by a URL, the returned value is undefined. sha1_hash info_hash() const; // comparison operators. The order of the torrents is unspecified diff --git a/src/torrent.cpp b/src/torrent.cpp index 008c2a823..6b2ca46df 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -164,6 +164,7 @@ namespace libtorrent , m_completed_time(0) , m_last_seen_complete(0) , m_swarm_last_seen_complete(0) + , m_info_hash(info_hash) , m_num_verified(0) , m_last_saved_resume(ses.session_time()) , m_started(ses.session_time()) @@ -620,6 +621,7 @@ namespace libtorrent alerts().post_alert(torrent_update_alert(get_handle(), info_hash(), tf->info_hash())); m_torrent_file = tf; + m_info_hash = tf->info_hash(); // now, we might already have this torrent in the session. boost::shared_ptr t = m_ses.find_torrent(m_torrent_file->info_hash()).lock(); @@ -8347,6 +8349,11 @@ namespace libtorrent TORRENT_ASSERT((!m_allow_peers || m_graceful_pause_mode) && is_seed()); break; } + if (m_torrent_file) + { + TORRENT_ASSERT(m_info_hash == m_torrent_file->info_hash()); + } + #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS for (int i = 0; i < aux::session_interface::num_torrent_lists; ++i) { diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index e2ac9f4c7..9e197f605 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -216,9 +216,10 @@ namespace libtorrent sha1_hash torrent_handle::info_hash() const { + boost::shared_ptr t = m_torrent.lock(); const static sha1_hash empty; - TORRENT_SYNC_CALL_RET(sha1_hash, empty, info_hash); - return r; + if (!t) return empty; + return t->info_hash(); } int torrent_handle::max_uploads() const diff --git a/test/Makefile.am b/test/Makefile.am index ac3a28a5b..dcbd7c86a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -177,6 +177,7 @@ test_time_critical_SOURCES = test_time_critical.cpp test_super_seeding_SOURCES = test_super_seeding.cpp test_swarm_SOURCES = test_swarm.cpp test_tailqueue_SOURCES = test_tailqueue.cpp +test_resume_SOURCES = test_resume.cpp test_rss_SOURCES = test_rss.cpp test_ssl_SOURCES = test_ssl.cpp test_threads_SOURCES = test_threads.cpp