diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-09-21 06:56:54 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2006-09-21 06:56:54 +0000 |
| commit | 65e0ffe6caa5f3ad9b4ccf49045f9e7ed144ee07 (patch) | |
| tree | 404fd056564901d0433d49dda78ae03a0f4b6475 /src/AbstractCommand.cc | |
| parent | 2fb9b5be9705560fd77b4244636bc2515e81f32c (diff) | |
2006-09-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/AbstractCommand.cc
(execute): Check whether the download has finished before
checking
socket status.
Return true if peerStat->getStatus() == REQUEST_IDLE.
Do not exit even if no segment is available.
* src/prefs.h
(PREF_STARTUP_IDLE_TIME): New definition.
* src/PeerInteractionCommand.cc
(executeInternal): Removed max speed limit. Because it performs
bad.
(receiveMessages): Added max speed limit. This was better than
above,
but still a little bit to be desired. Sometimes the download
speed
became much faster than I specified.
* src/SpeedCalc.h
(start): New variable.
(accumulatedLength): New variable.
(getAvgSpeed): New function.
* src/SpeedCalc.cc
(reset): Added start, accumulatedLength.
(update): Added calculation of an average speed.
(getAvgSpeed): New function.
* src/DownloadCommand.h
(sw): Removed.
* src/main.cc
(main): Added PREF_STARTUP_IDLE_TIME.
* src/PeerStat.h
(STATUS): Added REQUEST_IDLE.
(getMaxSpeed): Renamed as getMaxDownloadSpeed().
(getAvgDownloadSpeed): New function
(requestIdle): New function.
* src/SegmentMan.h
(SegmentEntryHandle): New type definition.
(SegmentEntries): Now holds SegmentEntryHandle.
(findSlowerSegmentEntry): New funtion.
* src/SegmentMan.cc
(save): Updated according to the changes in SegmentEntries.
(read): Updated according to the changes in SegmentEntries.
(FindSegmentEntryByIndex): Updated according to the changes in
SegmentEntries.
(FindSegmentEntryByCuid): Updated according to the changes in
SegmentEntries.
(checkoutSegment): Updated according to the changes in
SegmentEntries.
(onNullBitfield): Updated according to the changes in
SegmentEntries.
Renamed uitr as itr.
(findSlowerSegmentEntry): New function.
(getSegment): Updated according to the changes in
SegmentEntries.
Added the feature that cancels the segment with slow server and
fast
one takes it over.
(cancelSegment): Updated according to the changes in
SegmentEntries.
(getDownloadLength): Updated according to the changes in
SegmentEntries.
(init): Assigned 0 to bitfield after deleting it.
* src/DownloadCommand.cc
(STARTUP_IDLE_TIME): Removed.
(executeInternal): Use PREF_STARTUP_IDLE_TIME.
Diffstat (limited to 'src/AbstractCommand.cc')
| -rw-r--r-- | src/AbstractCommand.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 6a471277..2a9374e9 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -44,23 +44,34 @@ AbstractCommand::~AbstractCommand() { bool AbstractCommand::execute() { try { + if(e->segmentMan->finished()) { + logger->debug("CUID#%d - finished.", cuid); + return true; + } + PeerStatHandle peerStat = e->segmentMan->getPeerStat(cuid); + if(peerStat.get()) { + if(peerStat->getStatus() == PeerStat::REQUEST_IDLE) { + logger->info("CUID#%d - Request idle.", cuid); + onAbort(0); + req->resetUrl(); + tryReserved(); + return true; + } + } if(checkSocketIsReadable && readCheckTarget->isReadable(0) || checkSocketIsWritable && writeCheckTarget->isWritable(0) || !checkSocketIsReadable && !checkSocketIsWritable) { checkPoint.reset(); - if(e->segmentMan->finished()) { - logger->debug("CUID#%d - finished.", cuid); - return true; - } Segment segment; if(e->segmentMan->downloadStarted) { if(!e->segmentMan->getSegment(segment, cuid)) { logger->info(MSG_NO_SEGMENT_AVAILABLE, cuid); - return true; + return prepareForRetry(1); } } return executeInternal(segment); } else { + if(checkPoint.elapsed(timeout)) { throw new DlRetryEx(EX_TIME_OUT); } |
