*** empty log message ***

This commit is contained in:
Arvid Norberg 2004-02-29 16:39:52 +00:00
parent c035bb11f8
commit 567fd8112f
3 changed files with 50 additions and 2 deletions

View File

@ -139,6 +139,7 @@ namespace libtorrent
struct torrent_handle
{
friend class invariant_access;
friend class session;
friend class torrent;
@ -215,7 +216,14 @@ namespace libtorrent
: m_ses(s)
, m_chk(c)
, m_info_hash(h)
{}
{
assert(m_ses != 0);
assert(m_chk != 0);
}
#ifndef NDEBUG
void check_invariant() const;
#endif
detail::session_impl* m_ses;
detail::checker_impl* m_chk;

View File

@ -873,7 +873,8 @@ namespace libtorrent
void session::remove_torrent(const torrent_handle& h)
{
if (h.m_ses != &m_impl) return;
assert(h.m_chk == &m_checker_impl);
assert(h.m_chk == &m_checker_impl || h.m_chk == 0);
assert(h.m_ses != 0);
{
boost::mutex::scoped_lock l(m_impl.m_mutex);
@ -885,6 +886,7 @@ namespace libtorrent
}
}
if (h.m_chk)
{
boost::mutex::scoped_lock l(m_checker_impl.m_mutex);

View File

@ -59,6 +59,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/hasher.hpp"
#include "libtorrent/entry.hpp"
#include "libtorrent/session.hpp"
#include "libtorrent/invariant_check.hpp"
#if defined(_MSC_VER) && _MSC_VER < 1300
namespace std
@ -71,8 +72,19 @@ namespace std
namespace libtorrent
{
#ifndef NDEBUG
void torrent_handle::check_invariant() const
{
assert((m_ses == 0 && m_chk == 0) || (m_ses != 0));
}
#endif
void torrent_handle::set_max_uploads(int max_uploads)
{
INVARIANT_CHECK;
assert(max_uploads >= 2 || max_uploads == -1);
if (m_ses == 0) throw invalid_handle();
@ -104,6 +116,8 @@ namespace libtorrent
void torrent_handle::use_interface(const char* net_interface)
{
INVARIANT_CHECK;
if (m_ses == 0) throw invalid_handle();
{
@ -133,6 +147,8 @@ namespace libtorrent
void torrent_handle::set_max_connections(int max_connections)
{
INVARIANT_CHECK;
assert(max_connections > 2 || max_connections == -1);
if (m_ses == 0) throw invalid_handle();
@ -164,6 +180,8 @@ namespace libtorrent
torrent_status torrent_handle::status() const
{
INVARIANT_CHECK;
if (m_ses == 0) throw invalid_handle();
{
@ -196,6 +214,8 @@ namespace libtorrent
const torrent_info& torrent_handle::get_torrent_info() const
{
INVARIANT_CHECK;
if (m_ses == 0) throw invalid_handle();
{
@ -216,6 +236,8 @@ namespace libtorrent
void torrent_handle::set_tracker_login(std::string const& name, std::string const& password)
{
INVARIANT_CHECK;
if (m_ses == 0) throw invalid_handle();
{
@ -244,6 +266,8 @@ namespace libtorrent
bool torrent_handle::is_valid() const
{
INVARIANT_CHECK;
if (m_ses == 0) return false;
{
@ -264,6 +288,8 @@ namespace libtorrent
entry torrent_handle::write_resume_data() const
{
INVARIANT_CHECK;
std::vector<int> piece_index;
if (m_ses == 0)
throw invalid_handle();
@ -376,6 +402,8 @@ namespace libtorrent
boost::filesystem::path torrent_handle::save_path() const
{
INVARIANT_CHECK;
if (m_ses == 0) throw invalid_handle();
// copy the path into this local variable before
@ -411,6 +439,8 @@ namespace libtorrent
void torrent_handle::connect_peer(const address& adr) const
{
INVARIANT_CHECK;
if (m_ses == 0) throw invalid_handle();
boost::mutex::scoped_lock l(m_ses->m_mutex);
@ -424,6 +454,8 @@ namespace libtorrent
void torrent_handle::force_reannounce() const
{
INVARIANT_CHECK;
if (m_ses == 0) throw invalid_handle();
boost::mutex::scoped_lock l(m_ses->m_mutex);
@ -435,6 +467,8 @@ namespace libtorrent
void torrent_handle::set_ratio(float ratio)
{
INVARIANT_CHECK;
assert(ratio >= 0.f);
if (m_ses == 0) throw invalid_handle();
@ -464,6 +498,8 @@ namespace libtorrent
void torrent_handle::get_peer_info(std::vector<peer_info>& v) const
{
INVARIANT_CHECK;
v.clear();
if (m_ses == 0) throw invalid_handle();
@ -539,6 +575,8 @@ namespace libtorrent
void torrent_handle::get_download_queue(std::vector<partial_piece_info>& queue) const
{
INVARIANT_CHECK;
queue.clear();
if (m_ses == 0) throw invalid_handle();