From a5c91f683a8699c1618f9c078d64eb9da23280a5 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 5 Mar 2005 14:17:17 +0000 Subject: [PATCH] *** empty log message *** --- docs/manual.html | 10 ++++++++++ include/libtorrent/torrent.hpp | 4 ++-- src/peer_connection.cpp | 9 +++++++-- src/session.cpp | 3 +-- src/storage.cpp | 4 ++-- src/torrent.cpp | 12 ++++++++++++ 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/docs/manual.html b/docs/manual.html index 741f4a05c..f572e85b5 100755 --- a/docs/manual.html +++ b/docs/manual.html @@ -2205,6 +2205,16 @@ blocks specified by bitmask +file sizes +list where each entry corresponds to a file in the file list +in the metadata. Each entry has a list of two values, the +first value is the size of the file in bytes, the second +is the timestamp when the last time someone wrote to it. +This information is used to compare with the files on disk. +All the files must match exactly this information in order +to consider the resume data as current. Otherwise a full +re-check is issued. + diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index a10086ddb..861fd436c 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -115,7 +115,7 @@ namespace libtorrent // loop in session_impl will check for this state // on all torrents once every second, and take // the necessary actions then. - void abort() { m_abort = true; m_event = tracker_request::stopped; } + void abort(); bool is_aborted() const { return m_abort; } // is called every second by session. This will @@ -379,7 +379,7 @@ namespace libtorrent // blocks when requested int m_block_size; - // if this pointer is 0, the peer_connection is in + // if this pointer is 0, the torrent is in // a state where the metadata hasn't been // received yet. std::auto_ptr m_storage; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index f4042a191..0ccebf99b 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1310,10 +1310,13 @@ namespace libtorrent void peer_connection::disconnect() { if (m_disconnecting) return; - detail::session_impl::connection_map::iterator i = m_ses.m_connections.find(m_socket); + detail::session_impl::connection_map::iterator i + = m_ses.m_connections.find(m_socket); m_disconnecting = true; assert(i != m_ses.m_connections.end()); - assert(std::find(m_ses.m_disconnect_peer.begin(), m_ses.m_disconnect_peer.end(), i) == m_ses.m_disconnect_peer.end()); + assert(std::find(m_ses.m_disconnect_peer.begin() + , m_ses.m_disconnect_peer.end(), i) + == m_ses.m_disconnect_peer.end()); m_ses.m_disconnect_peer.push_back(i); } @@ -1849,6 +1852,7 @@ namespace libtorrent { INVARIANT_CHECK; + assert(!m_disconnecting); assert(!m_socket->is_blocking()); assert(m_packet_size > 0); assert(m_socket->is_readable()); @@ -2158,6 +2162,7 @@ namespace libtorrent { INVARIANT_CHECK; + assert(!m_disconnecting); assert(m_socket->is_writable()); assert(can_write()); diff --git a/src/session.cpp b/src/session.cpp index f5dc5d6d4..b6c7f3f76 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -404,6 +404,7 @@ namespace libtorrent { namespace detail #ifndef NDEBUG check_invariant("before abort"); #endif + purge_connections(); if (m_abort) { @@ -690,8 +691,6 @@ namespace libtorrent { namespace detail req.listen_port = m_listen_interface.port; req.key = m_key; m_tracker_manager.queue_request(req, t.tracker_login()); - t.disconnect_all(); - purge_connections(); #ifndef NDEBUG sha1_hash i_hash = t.torrent_file().info_hash(); #endif diff --git a/src/storage.cpp b/src/storage.cpp index d8d1ce504..dd188f591 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -187,7 +187,7 @@ namespace libtorrent size = file_size(f); time = last_write_time(f); } - catch (file_error&) {} + catch (std::exception&) {} sizes.push_back(std::make_pair(size, time)); } return sizes; @@ -215,7 +215,7 @@ namespace libtorrent size = file_size(f); time = last_write_time(f); } - catch (file_error&) {} + catch (std::exception&) {} if (size != s->first || time != s->second) return false; } diff --git a/src/torrent.cpp b/src/torrent.cpp index ed8720803..5378007b2 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -493,6 +493,15 @@ namespace libtorrent assert(m_have_pieces[index] == false); } + void torrent::abort() + { + m_abort = true; + m_event = tracker_request::stopped; + // disconnect all peers and close all + // files belonging to the torrent + disconnect_all(); + m_storage.release(); + } void torrent::announce_piece(int index) { @@ -829,6 +838,9 @@ namespace libtorrent // tell the tracker that we stopped m_event = tracker_request::stopped; m_just_paused = true; + // this will make the storage close all + // files and flush all cached data + if (m_storage.get()) m_storage->release(); } void torrent::resume()