mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-19 15:46:17 +00:00
* Properly handle NULL ptr in target_any commands.
* Enable PEX by default. * Renamed Download::start2/stop2. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1006 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -315,7 +315,7 @@ initialize_command_network() {
|
|||||||
ADD_COMMAND_VALUE_UN("enable_trackers", std::ptr_fun(&apply_enable_trackers));
|
ADD_COMMAND_VALUE_UN("enable_trackers", std::ptr_fun(&apply_enable_trackers));
|
||||||
ADD_COMMAND_STRING_UN("encoding_list", std::ptr_fun(&apply_encoding_list));
|
ADD_COMMAND_STRING_UN("encoding_list", std::ptr_fun(&apply_encoding_list));
|
||||||
|
|
||||||
ADD_VARIABLE_BOOL("peer_exchange", false);
|
ADD_VARIABLE_BOOL("peer_exchange", true);
|
||||||
|
|
||||||
// Not really network stuff:
|
// Not really network stuff:
|
||||||
ADD_VARIABLE_BOOL("handshake_log", false);
|
ADD_VARIABLE_BOOL("handshake_log", false);
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ DownloadList::close_try(Download* download) {
|
|||||||
void
|
void
|
||||||
DownloadList::close_directly(Download* download) {
|
DownloadList::close_directly(Download* download) {
|
||||||
if (download->download()->is_active()) {
|
if (download->download()->is_active()) {
|
||||||
download->download()->stop2(torrent::Download::stop_skip_tracker);
|
download->download()->stop(torrent::Download::stop_skip_tracker);
|
||||||
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ DownloadList::resume(Download* download, int flags) {
|
|||||||
// Update the priority to ensure it has the correct
|
// Update the priority to ensure it has the correct
|
||||||
// seeding/unfinished modifiers.
|
// seeding/unfinished modifiers.
|
||||||
download->set_priority(download->priority());
|
download->set_priority(download->priority());
|
||||||
download->download()->start2(download->resume_flags());
|
download->download()->start(download->resume_flags());
|
||||||
|
|
||||||
download->set_resume_flags(~uint32_t());
|
download->set_resume_flags(~uint32_t());
|
||||||
|
|
||||||
@@ -438,7 +438,7 @@ DownloadList::pause(Download* download, int flags) {
|
|||||||
if (!download->download()->is_active())
|
if (!download->download()->is_active())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
download->download()->stop2(flags);
|
download->download()->stop(flags);
|
||||||
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
torrent::resume_save_progress(*download->download(), download->download()->bencode()->get_key("libtorrent_resume"));
|
||||||
|
|
||||||
std::for_each(slot_map_stop().begin(), slot_map_stop().end(), download_list_call(download));
|
std::for_each(slot_map_stop().begin(), slot_map_stop().end(), download_list_call(download));
|
||||||
|
|||||||
+17
-5
@@ -149,11 +149,15 @@ CommandMap::call_command(key_type key, const mapped_type& arg, target_type targe
|
|||||||
if (itr == base_type::end())
|
if (itr == base_type::end())
|
||||||
throw torrent::input_error("Command \"" + std::string(key) + "\" does not exist.");
|
throw torrent::input_error("Command \"" + std::string(key) + "\" does not exist.");
|
||||||
|
|
||||||
if (target.second == NULL &&
|
if (target.first != target_generic && target.second == NULL) {
|
||||||
itr->second.m_target != target_generic &&
|
// We received a target that is NULL, so throw an exception unless
|
||||||
!(itr->second.m_target == target_any && target.first == target_generic))
|
// we can convert it to a void target.
|
||||||
|
if (itr->second.m_target > target_any)
|
||||||
throw torrent::input_error("Command type mis-match.");
|
throw torrent::input_error("Command type mis-match.");
|
||||||
|
|
||||||
|
target.first = target_generic;
|
||||||
|
}
|
||||||
|
|
||||||
if (itr->second.m_target != target.first && itr->second.m_target > target_any) {
|
if (itr->second.m_target != target.first && itr->second.m_target > target_any) {
|
||||||
// Mismatch between the target and command type. If it is not
|
// Mismatch between the target and command type. If it is not
|
||||||
// possible to convert, then throw an input error.
|
// possible to convert, then throw an input error.
|
||||||
@@ -178,8 +182,16 @@ CommandMap::call_command(key_type key, const mapped_type& arg, target_type targe
|
|||||||
|
|
||||||
const CommandMap::mapped_type
|
const CommandMap::mapped_type
|
||||||
CommandMap::call_command(const_iterator itr, const mapped_type& arg, target_type target) {
|
CommandMap::call_command(const_iterator itr, const mapped_type& arg, target_type target) {
|
||||||
if ((itr->second.m_target != target.first && itr->second.m_target > target_any) ||
|
if (target.first != target_generic && target.second == NULL) {
|
||||||
(target.second == NULL && itr->second.m_target != target_generic && !(itr->second.m_target == target_any && target.first == target_generic)))
|
// We received a target that is NULL, so throw an exception unless
|
||||||
|
// we can convert it to a void target.
|
||||||
|
if (itr->second.m_target > target_any)
|
||||||
|
throw torrent::input_error("Command type mis-match.");
|
||||||
|
|
||||||
|
target.first = target_generic;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itr->second.m_target != target.first && itr->second.m_target > target_any)
|
||||||
throw torrent::input_error("Command type mis-match.");
|
throw torrent::input_error("Command type mis-match.");
|
||||||
|
|
||||||
// This _should_ be optimized int just two calls.
|
// This _should_ be optimized int just two calls.
|
||||||
|
|||||||
Reference in New Issue
Block a user