diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-07-06 14:35:42 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-07-06 14:35:42 +0000 |
| commit | db84b1b65237acfe5a231bea2dd28c3795400f33 (patch) | |
| tree | 16229dde0fbf2ac6329471c032e819494b13e949 /src/CreateRequestCommand.cc | |
| parent | 69c3dfded4f2816ce734828e3a7dbae6caf32a8e (diff) | |
2009-07-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Keep CreateRequestCommand in queue when no segment is available so
that they can pick up pieces which slow BitTorrent peers are
downloading.
* src/AbstractCommand.cc
* src/CreateRequestCommand.cc
* src/CreateRequestCommand.h
Diffstat (limited to 'src/CreateRequestCommand.cc')
| -rw-r--r-- | src/CreateRequestCommand.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/CreateRequestCommand.cc b/src/CreateRequestCommand.cc index 06782ffd..014b8a0b 100644 --- a/src/CreateRequestCommand.cc +++ b/src/CreateRequestCommand.cc @@ -44,6 +44,8 @@ #include "SegmentMan.h" #include "prefs.h" #include "Option.h" +#include "SleepCommand.h" +#include "Logger.h" namespace aria2 { @@ -57,7 +59,7 @@ CreateRequestCommand::CreateRequestCommand(int32_t cuid, disableReadCheckSocket(); disableWriteCheckSocket(); } - + bool CreateRequestCommand::executeInternal() { if(_segments.empty()) { @@ -95,4 +97,20 @@ bool CreateRequestCommand::executeInternal() return true; } +bool CreateRequestCommand::prepareForRetry(time_t wait) +{ + // We assume that this method is called from AbstractCommand when + // Segment is not available. Normally, + // AbstractCommand::prepareForRetry() does the job, but it creates + // CreateRequestCommand and deletes current one. At the last stage + // of the download, commands are idle and prepareForRetry() is + // called repeatedly. This means that newly created + // CreateRequestCommand is deleted one second later: This is not + // efficient. For this reason, reuse current CreateRequestCommand. + logger->debug("CUID#%d - Reusing CreateRequestCommand", cuid); + SleepCommand* scom = new SleepCommand(cuid, e, _requestGroup, this, wait); + e->commands.push_back(scom); + return false; +} + } // namespace aria2 |
