Browse Source
* Removed core::HashQueue, using the "hashing" view and a function in
* Removed core::HashQueue, using the "hashing" view and a function in
core::Manager instead. * Added a new :rtorrent:hashing state so we can distinguish between initial hashing and manual rehashes. The former is cleared if the download is paused. * Added a hash failed flag to core::Download. This is used to skip entries in the hashing view that either failed to open or are in the process of being erased from DownloadList. * torrent::Bitfield::unset was incrementing, rather than decrementing, the m_set counter. * Replaced all torrent::internal_error's in rtorrent with torrent::client_error. * ^D now checks :rtorrent:state to decide whetever to stop or erase a download. Downloads queued for hashing will now stop rather than be deleted. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@688 e378c898-3ddf-0310-93e7-cc216c733640pull/30/head
22 changed files with 177 additions and 346 deletions
-
6src/command_scheduler.cc
-
4src/command_scheduler_item.cc
-
1src/control.cc
-
2src/core/Makefile.am
-
2src/core/download.cc
-
16src/core/download.h
-
122src/core/download_list.cc
-
6src/core/download_list.h
-
125src/core/hash_queue.cc
-
109src/core/hash_queue.h
-
43src/core/manager.cc
-
11src/core/manager.h
-
4src/core/scheduler.cc
-
16src/core/view.cc
-
3src/core/view.h
-
3src/core/view_manager.cc
-
14src/display/utils.cc
-
2src/display/window_download_list.cc
-
6src/ui/download_list.cc
-
12src/ui/element_file_list.cc
-
14src/ui/element_tracker_list.cc
-
2src/utils/variable_map.cc
@ -1,125 +0,0 @@ |
|||
// rTorrent - BitTorrent client
|
|||
// Copyright (C) 2005-2006, Jari Sundell
|
|||
//
|
|||
// This program is free software; you can redistribute it and/or modify
|
|||
// it under the terms of the GNU General Public License as published by
|
|||
// the Free Software Foundation; either version 2 of the License, or
|
|||
// (at your option) any later version.
|
|||
//
|
|||
// This program is distributed in the hope that it will be useful,
|
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||
// GNU General Public License for more details.
|
|||
//
|
|||
// You should have received a copy of the GNU General Public License
|
|||
// along with this program; if not, write to the Free Software
|
|||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
//
|
|||
// In addition, as a special exception, the copyright holders give
|
|||
// permission to link the code of portions of this program with the
|
|||
// OpenSSL library under certain conditions as described in each
|
|||
// individual source file, and distribute linked combinations
|
|||
// including the two.
|
|||
//
|
|||
// You must obey the GNU General Public License in all respects for
|
|||
// all of the code used other than OpenSSL. If you modify file(s)
|
|||
// with this exception, you may extend this exception to your version
|
|||
// of the file(s), but you are not obligated to do so. If you do not
|
|||
// wish to do so, delete this exception statement from your version.
|
|||
// If you delete this exception statement from all source files in the
|
|||
// program, then also delete it here.
|
|||
//
|
|||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
|||
//
|
|||
// Skomakerveien 33
|
|||
// 3185 Skoppum, NORWAY
|
|||
|
|||
#include "config.h"
|
|||
|
|||
#include <algorithm>
|
|||
#include <stdexcept>
|
|||
#include <sigc++/bind.h>
|
|||
|
|||
#include "download.h"
|
|||
#include "download_list.h"
|
|||
#include "rak/functional.h"
|
|||
#include "hash_queue.h"
|
|||
|
|||
namespace core { |
|||
|
|||
bool |
|||
HashQueue::is_queued(Download* download) const { |
|||
return |
|||
download->download()->is_hash_checking() || |
|||
std::find_if(begin(), end(), rak::equal(download, std::mem_fun(&HashQueueNode::download))) != end(); |
|||
} |
|||
|
|||
void |
|||
HashQueue::insert(Download* download) { |
|||
if (download->download()->is_hash_checking() || find(download) != end()) |
|||
return; |
|||
|
|||
if (download->download()->is_hash_checked()) { |
|||
m_downloadList->hash_done(download); |
|||
return; |
|||
} |
|||
|
|||
if (find(download) != end()) |
|||
throw torrent::internal_error("HashQueue::insert(...) download already in queue."); |
|||
|
|||
iterator itr = Base::insert(end(), new HashQueueNode(download)); |
|||
|
|||
(*itr)->set_connection(download->download()->signal_hash_done(sigc::bind(sigc::mem_fun(*this, &HashQueue::receive_hash_done), download))); |
|||
|
|||
fill_queue(); |
|||
} |
|||
|
|||
void |
|||
HashQueue::remove(Download* d) { |
|||
iterator itr = find(d); |
|||
|
|||
if (itr == end()) |
|||
return; |
|||
|
|||
// We don't do anything if we're already checking, just disconnect.
|
|||
// if ((*itr)->download()->download()->is_hash_checking()) {
|
|||
// // What do we do if we're already checking?
|
|||
// }
|
|||
|
|||
delete *itr; |
|||
Base::erase(itr); |
|||
|
|||
fill_queue(); |
|||
} |
|||
|
|||
HashQueue::iterator |
|||
HashQueue::find(Download* d) { |
|||
return std::find_if(begin(), end(), rak::equal(d, std::mem_fun(&HashQueueNode::download))); |
|||
} |
|||
|
|||
void |
|||
HashQueue::receive_hash_done(Download* d) { |
|||
iterator itr = find(d); |
|||
|
|||
if (itr == end()) |
|||
return; |
|||
|
|||
delete *itr; |
|||
Base::erase(itr); |
|||
|
|||
m_downloadList->hash_done(d); |
|||
fill_queue(); |
|||
} |
|||
|
|||
void |
|||
HashQueue::fill_queue() { |
|||
if (empty() || front()->download()->download()->is_hash_checking()) |
|||
return; |
|||
|
|||
if (front()->download()->download()->is_hash_checked()) |
|||
throw std::logic_error("core::HashQueue::fill_queue() encountered a checked hash"); |
|||
|
|||
front()->download()->download()->hash_check(); |
|||
} |
|||
|
|||
} |
@ -1,109 +0,0 @@ |
|||
// rTorrent - BitTorrent client |
|||
// Copyright (C) 2005-2006, Jari Sundell |
|||
// |
|||
// This program is free software; you can redistribute it and/or modify |
|||
// it under the terms of the GNU General Public License as published by |
|||
// the Free Software Foundation; either version 2 of the License, or |
|||
// (at your option) any later version. |
|||
// |
|||
// This program is distributed in the hope that it will be useful, |
|||
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
// GNU General Public License for more details. |
|||
// |
|||
// You should have received a copy of the GNU General Public License |
|||
// along with this program; if not, write to the Free Software |
|||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|||
// |
|||
// In addition, as a special exception, the copyright holders give |
|||
// permission to link the code of portions of this program with the |
|||
// OpenSSL library under certain conditions as described in each |
|||
// individual source file, and distribute linked combinations |
|||
// including the two. |
|||
// |
|||
// You must obey the GNU General Public License in all respects for |
|||
// all of the code used other than OpenSSL. If you modify file(s) |
|||
// with this exception, you may extend this exception to your version |
|||
// of the file(s), but you are not obligated to do so. If you do not |
|||
// wish to do so, delete this exception statement from your version. |
|||
// If you delete this exception statement from all source files in the |
|||
// program, then also delete it here. |
|||
// |
|||
// Contact: Jari Sundell <jaris@ifi.uio.no> |
|||
// |
|||
// Skomakerveien 33 |
|||
// 3185 Skoppum, NORWAY |
|||
|
|||
#ifndef RTORRENT_CORE_HASH_QUEUE_H |
|||
#define RTORRENT_CORE_HASH_QUEUE_H |
|||
|
|||
#include <list> |
|||
#include <sigc++/slot.h> |
|||
#include <sigc++/connection.h> |
|||
|
|||
namespace core { |
|||
|
|||
class Download; |
|||
class DownloadList; |
|||
|
|||
class HashQueueNode; |
|||
|
|||
class HashQueue : private std::list<HashQueueNode*> { |
|||
public: |
|||
typedef std::list<HashQueueNode*> Base; |
|||
|
|||
using Base::iterator; |
|||
using Base::const_iterator; |
|||
using Base::reverse_iterator; |
|||
using Base::const_reverse_iterator; |
|||
|
|||
using Base::begin; |
|||
using Base::end; |
|||
using Base::rbegin; |
|||
using Base::rend; |
|||
|
|||
using Base::front; |
|||
using Base::back; |
|||
|
|||
using Base::empty; |
|||
using Base::size; |
|||
|
|||
// Replace 'dl' with a slot. |
|||
HashQueue(DownloadList* dl) : m_downloadList(dl) {} |
|||
|
|||
bool is_queued(Download* download) const; |
|||
|
|||
void insert(Download* d); |
|||
|
|||
// It's safe to try to remove downloads not in the queue. The hash |
|||
// checking is not stopped if it has already started. |
|||
void remove(Download* d); |
|||
|
|||
iterator find(Download* d); |
|||
|
|||
private: |
|||
void receive_hash_done(Download* d); |
|||
|
|||
void fill_queue(); |
|||
|
|||
DownloadList* m_downloadList; |
|||
}; |
|||
|
|||
class HashQueueNode { |
|||
public: |
|||
HashQueueNode(Download* d) : m_download(d) {} |
|||
~HashQueueNode() { disconnect(); } |
|||
|
|||
void disconnect() { m_connection.disconnect(); } |
|||
Download* download() { return m_download; } |
|||
|
|||
void set_connection(sigc::connection c) { m_connection = c; } |
|||
|
|||
private: |
|||
Download* m_download; |
|||
sigc::connection m_connection; |
|||
}; |
|||
|
|||
} |
|||
|
|||
#endif |
Write
Preview
Loading…
Cancel
Save
Reference in new issue