2009-07-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added --bt-stop-timeout=SEC option. This function stops BitTorrent
	download if the download speed is 0 and the number of seeder is 0
	in consecutive SEC seconds. By default, this function is disabled.
	* src/BtSetup.cc
	* src/Makefile.am
	* src/OptionHandlerFactory.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
pull/1/head
Tatsuhiro Tsujikawa 2009-07-05 03:11:51 +00:00
parent 051052e9e2
commit b2f0577225
8 changed files with 48 additions and 5 deletions

View File

@ -1,3 +1,15 @@
2009-07-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --bt-stop-timeout=SEC option. This function stops BitTorrent
download if the download speed is 0 and the number of seeder is 0
in consecutive SEC seconds. By default, this function is disabled.
* src/BtSetup.cc
* src/Makefile.am
* src/OptionHandlerFactory.cc
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
2009-07-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Removed the call to DiskAdaptor::onDownloadComplete() from

View File

@ -59,6 +59,7 @@
#include "BtAnnounce.h"
#include "BtRuntime.h"
#include "bittorrent_helper.h"
#include "BtStopDownloadCommand.h"
namespace aria2 {
@ -158,7 +159,15 @@ void BtSetup::setup(std::deque<Command*>& commands,
delete listenCommand;
}
}
time_t btStopTimeout = option->getAsInt(PREF_BT_STOP_TIMEOUT);
if(btStopTimeout > 0) {
BtStopDownloadCommand* stopDownloadCommand =
new BtStopDownloadCommand(e->newCUID(), requestGroup, e, btStopTimeout);
stopDownloadCommand->setBtRuntime(btRuntime);
stopDownloadCommand->setPieceStorage(pieceStorage);
stopDownloadCommand->setPeerStorage(peerStorage);
commands.push_back(stopDownloadCommand);
}
btRuntime->setReady(true);
}

View File

@ -434,7 +434,8 @@ SRCS += PeerMessageUtil.cc PeerMessageUtil.h\
IndexBtMessageValidator.h\
ExtensionMessageRegistry.h\
bencode.cc bencode.h\
bittorrent_helper.cc bittorrent_helper.h
bittorrent_helper.cc bittorrent_helper.h\
BtStopDownloadCommand.cc BtStopDownloadCommand.h
endif # ENABLE_BITTORRENT
if ENABLE_METALINK

View File

@ -230,7 +230,8 @@ bin_PROGRAMS = aria2c$(EXEEXT)
@ENABLE_BITTORRENT_TRUE@ IndexBtMessageValidator.h\
@ENABLE_BITTORRENT_TRUE@ ExtensionMessageRegistry.h\
@ENABLE_BITTORRENT_TRUE@ bencode.cc bencode.h\
@ENABLE_BITTORRENT_TRUE@ bittorrent_helper.cc bittorrent_helper.h
@ENABLE_BITTORRENT_TRUE@ bittorrent_helper.cc bittorrent_helper.h\
@ENABLE_BITTORRENT_TRUE@ BtStopDownloadCommand.cc BtStopDownloadCommand.h
@ENABLE_METALINK_TRUE@am__append_14 = Metalinker.cc Metalinker.h\
@ENABLE_METALINK_TRUE@ MetalinkEntry.cc MetalinkEntry.h\
@ -562,7 +563,8 @@ am__libaria2c_a_SOURCES_DIST = Socket.h SocketCore.cc SocketCore.h \
ZeroBtMessage.h RangeBtMessageValidator.h \
IndexBtMessageValidator.h ExtensionMessageRegistry.h \
bencode.cc bencode.h bittorrent_helper.cc bittorrent_helper.h \
Metalinker.cc Metalinker.h MetalinkEntry.cc MetalinkEntry.h \
BtStopDownloadCommand.cc BtStopDownloadCommand.h Metalinker.cc \
Metalinker.h MetalinkEntry.cc MetalinkEntry.h \
MetalinkResource.cc MetalinkResource.h MetalinkProcessor.h \
MetalinkParserController.cc MetalinkParserController.h \
MetalinkParserStateMachine.cc MetalinkParserStateMachine.h \
@ -731,7 +733,8 @@ am__objects_6 =
@ENABLE_BITTORRENT_TRUE@ IndexBtMessage.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ ZeroBtMessage.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ bencode.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ bittorrent_helper.$(OBJEXT)
@ENABLE_BITTORRENT_TRUE@ bittorrent_helper.$(OBJEXT) \
@ENABLE_BITTORRENT_TRUE@ BtStopDownloadCommand.$(OBJEXT)
@ENABLE_METALINK_TRUE@am__objects_14 = Metalinker.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkEntry.$(OBJEXT) \
@ENABLE_METALINK_TRUE@ MetalinkResource.$(OBJEXT) \
@ -1320,6 +1323,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtRequestMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtSeederStateChoke.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtSetup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtStopDownloadCommand.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtSuggestPieceMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BtUnchokeMessage.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ByteArrayDiskWriter.Po@am__quote@

View File

@ -988,6 +988,15 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_BITTORRENT);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new NumberOptionHandler
(PREF_BT_STOP_TIMEOUT,
TEXT_BT_STOP_TIMEOUT,
"0",
0));
op->addTag(TAG_BITTORRENT);
handlers.push_back(op);
}
{
SharedHandle<NumberOptionHandler> op(new NumberOptionHandler
(PREF_BT_TIMEOUT,

View File

@ -303,6 +303,8 @@ const std::string PREF_BT_EXTERNAL_IP("bt-external-ip");
const std::string PREF_INDEX_OUT("index-out");
// values: 1*digit
const std::string PREF_BT_TRACKER_INTERVAL("bt-tracker-interval");
// values: 1*digit
const std::string PREF_BT_STOP_TIMEOUT("bt-stop-timeout");
/**
* Metalink related preferences

View File

@ -307,6 +307,8 @@ extern const std::string PREF_BT_EXTERNAL_IP;
extern const std::string PREF_INDEX_OUT;
// values: 1*digit
extern const std::string PREF_BT_TRACKER_INTERVAL;
// values: 1*digit
extern const std::string PREF_BT_STOP_TIMEOUT;
/**
* Metalink related preferences

View File

@ -558,3 +558,7 @@ _(" --on-download-stop=COMMAND Set the command to be executed when download\n"
" option is not executed.\n"\
" See --on-download-start option for the\n"\
" requirement of COMMAND.")
#define TEXT_BT_STOP_TIMEOUT \
_(" --bt-stop-timteout=SEC Stop BitTorrent download if download speed is 0\n"\
" and the number of seeder is 0 in consecutive NUM\n"\
" seconds. If 0 is given, this feature is disabled.")