mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-10 16:19:23 +00:00
* Minor cleanup in rtorrent.
* Changing priorities of closed torrents caused a crash due to empty ChunkSelector, fixed. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@615 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+20
-24
@@ -46,10 +46,29 @@
|
||||
|
||||
namespace core {
|
||||
|
||||
Download::Download() :
|
||||
Download::Download(torrent::Download d) :
|
||||
m_download(d),
|
||||
|
||||
m_chunksFailed(0),
|
||||
m_connectionLeech(torrent::Download::CONNECTION_LEECH),
|
||||
m_connectionSeed(torrent::Download::CONNECTION_SEED) {
|
||||
|
||||
m_connTrackerSucceded = m_download.signal_tracker_succeded(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), ""));
|
||||
m_connTrackerFailed = m_download.signal_tracker_failed(sigc::mem_fun(*this, &Download::receive_tracker_msg));
|
||||
m_connStorageError = m_download.signal_storage_error(sigc::mem_fun(*this, &Download::receive_storage_error));
|
||||
|
||||
m_download.signal_chunk_failed(sigc::mem_fun(*this, &Download::receive_chunk_failed));
|
||||
}
|
||||
|
||||
Download::~Download() {
|
||||
if (!m_download.is_valid())
|
||||
return;
|
||||
|
||||
m_connTrackerSucceded.disconnect();
|
||||
m_connTrackerFailed.disconnect();
|
||||
m_connStorageError.disconnect();
|
||||
|
||||
m_download = torrent::Download();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -65,17 +84,6 @@ Download::start() {
|
||||
m_download.start();
|
||||
}
|
||||
|
||||
void
|
||||
Download::set_download(torrent::Download d) {
|
||||
m_download = d;
|
||||
|
||||
m_connTrackerSucceded = m_download.signal_tracker_succeded(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), ""));
|
||||
m_connTrackerFailed = m_download.signal_tracker_failed(sigc::mem_fun(*this, &Download::receive_tracker_msg));
|
||||
m_connStorageError = m_download.signal_storage_error(sigc::mem_fun(*this, &Download::receive_storage_error));
|
||||
|
||||
m_download.signal_chunk_failed(sigc::mem_fun(*this, &Download::receive_chunk_failed));
|
||||
}
|
||||
|
||||
void
|
||||
Download::set_root_directory(const std::string& d) {
|
||||
m_download.set_root_dir(d +
|
||||
@@ -93,18 +101,6 @@ Download::enable_udp_trackers(bool state) {
|
||||
m_download.tracker(i).disable();
|
||||
}
|
||||
|
||||
void
|
||||
Download::release_download() {
|
||||
if (!m_download.is_valid())
|
||||
return;
|
||||
|
||||
m_connTrackerSucceded.disconnect();
|
||||
m_connTrackerFailed.disconnect();
|
||||
m_connStorageError.disconnect();
|
||||
|
||||
m_download = torrent::Download();
|
||||
}
|
||||
|
||||
void
|
||||
Download::receive_finished() {
|
||||
m_download.set_connection_type(m_connectionSeed);
|
||||
|
||||
+2
-5
@@ -47,17 +47,14 @@ class Download {
|
||||
public:
|
||||
typedef torrent::Download::ConnectionType ConnType;
|
||||
|
||||
Download();
|
||||
~Download() { release_download(); }
|
||||
Download(torrent::Download d);
|
||||
~Download();
|
||||
|
||||
bool is_open() { return m_download.is_open(); }
|
||||
inline bool is_done();
|
||||
|
||||
void start();
|
||||
|
||||
void set_download(torrent::Download d);
|
||||
void release_download();
|
||||
|
||||
torrent::Download& get_download() { return m_download; }
|
||||
const torrent::Download& get_download() const { return m_download; }
|
||||
std::string get_hash() { return m_download.info_hash(); }
|
||||
|
||||
@@ -51,8 +51,7 @@ DownloadList::iterator
|
||||
DownloadList::insert(std::istream* str) {
|
||||
torrent::Download d = torrent::download_add(str);
|
||||
|
||||
iterator itr = Base::insert(end(), new Download);
|
||||
(*itr)->set_download(d);
|
||||
iterator itr = Base::insert(end(), new Download(d));
|
||||
(*itr)->get_download().signal_download_done(sigc::bind(sigc::mem_fun(*this, &DownloadList::finished), *itr));
|
||||
|
||||
m_slotMapInsert.for_each(*itr);
|
||||
@@ -65,7 +64,6 @@ DownloadList::erase(iterator itr) {
|
||||
m_slotMapErase.for_each(*itr);
|
||||
|
||||
torrent::download_remove((*itr)->get_download());
|
||||
(*itr)->release_download();
|
||||
delete *itr;
|
||||
|
||||
return Base::erase(itr);
|
||||
|
||||
@@ -98,7 +98,6 @@ Manager::initialize_second() {
|
||||
m_httpQueue.slot_factory(m_pollManager->get_http_stack()->get_http_factory());
|
||||
|
||||
CurlStack::global_init();
|
||||
listen_open();
|
||||
|
||||
// Register slots to be called when a download is inserted/erased,
|
||||
// opened or closed.
|
||||
|
||||
Reference in New Issue
Block a user