* src/Request.h: Use AuthResolver to get authentication
information.
* src/main.cc: Made RequestFactory a singleton object. Netrc is
now
set to RequestFactory object.
* src/AuthConfigItem.h, src/AuthConfigItem.cc: Removed.
* src/AuthConfig.h, src/AuthConfig.cc: Rewritten.
* src/TrackerWatcherComand.cc: Use RequestFactorySingletonHolder
to
create Request object.
To integrate Netrc into exsiting classes:
* src/Request.h
(_userDefinedAuthConfig): New variable.
(findNetrcAuthenticator): New function.
(segment): Removed.
(setUserDefinedAuthConfig): New function.
(resolveHttpAuthConfigItem): New function.
(resolveFtpAuthConfigItem): New function.
(resolveHttpProxyAuthConfigItem): New function.
* src/HttpRequest.h
(authConfig): Removed.
(proxyAuthConfig): Removed.
(setAuthConfig): Removed.
(setProxyAuthConfig): Removed.
* src/UrlRequest.h
(getHeadResult): Added a parameter: authConfigHandle
* src/common.h
(SingletonHolder.h): New include.
* src/main.cc
(Netrc.h): New include.
(main): Removed initial values of PREF_FTP_USER,
PREF_FTP_PASSWD.
Added initial value of PREF_NETRC_PATH.
Added the initialization of netrc.
* src/AuthConfig.h: New class.
* src/prefs.h
(PREF_NETRC_PATH): New definition.
* src/HttpAuthConfig.h: Removed.
* src/Netrc.cc
(getRequiredNextToken): New function.
(skipMacdef): New function.
(parse): Rewritten.
* src/Netrc.h
(getRequiredNextToken): New function.
(skipMacdef): New function.
* src/Util.h, src/Util.cc
(getHomeDir): New function.
* src/TrackerWatcherComand.cc
(createRequestCommand): Use AuthConfig.
* src/FtpConnection.cc
(sendUser): Use Request::resolveFtpAuthConfigItem().
(sendPass): Use Request::resolveFtpAuthConfigItem().
* src/Request.cc
(findNetrcAuthenticator): New function.
(resolveHttpAuthConfigItem): New function.
(resolveFtpAuthConfigItem): New function.
(resolveHttpProxyAuthConfigItem): New function.
* src/UrlRequestInfo.cc: Use AuthConfig.
* src/HttpRequest.cc
(createRequest): Use authConfig.
(getProxyAuthString): Use authConfig.
(configure): Removed PREF_HTTP_USER, PREF_HTTP_PASSWD,
PREF_HTTP_PROXY_USER, PREF_HTTP_PROXY_PASSWD.
To reduce overhead to find commands whose socket is either
readable or writable in the download engine loop:
* src/Command.h, src/Command.cc
(STATUS): New enum.
(status): New variable.
(statusMatch): New function.
(setStatusActive): New function.
(setStatusInactive): New function.
* src/DownloadEngine.h, src/DownloadEngine.cc
(executeCommand): New function.
(run): Simplified.
(waitData): Call Command::setStatusActive() when command's
socket is
readable or writable.
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
* src/HttpHeader.h
(Range.h): New include.
(status): New variable.
(HttpHeader): Initialized status with 0.
(getStatus): New function.
(setStatus): New function.
(getRange): New function.
(HttpHeaderHandle): New function.
* src/HttpHeader.cc
(getRange): New function.
* src/Request.h
(RequestWeakHandle): New definition.
* src/HttpConnection.h
(HttpConnectionHandle): New type definition.
* src/HttpConnection.cc
(receiveResponse): Set HTTP status to headers.
* src/main.cc
(showUsage): Fixed typo.
* src/Segment.h
(SegmentHandle): New type definition.
* src/BitfieldMan.h
(getMissingUnusedLength): New function.
* src/BitfieldMan.cc
(getMissingUnusedLength): New function.
To fix the bug that causes crash on Max OS X:
* src/SimpleRandomizer.h
(getInstance): Create new instance if the static variable is
null.
* src/SimpleRandomizer.cc
(randomizer): Initialized to 0.
* src/BitfieldManFactory.h
(getNewFactory): Removed the call to setRandomizer().
To fix the miscalculation of the range of checksum:
* src/BitfieldMan.h
(isBitSetOffsetRange): New function.
* src/BitfieldMan.cc
(isBitSetOffsetRange): New function.
* src/SegmentMan.cc
(tryChunkChecksumValidation): Use
BitfieldMan::isBitSetOffsetRange().
Use bitfield->getBlockLength() instead of segment.segmentLength.
To lower CPU usage in BitTorrent download when
--max-upload-limit
command-line option specified:
* src/DefaultBtMessageDispatcher.cc
(sendMessages): Calculate uploading speed only when current
message
is uploading data and is not sent yet.
* src/DefaultPeerStorage.h
(MAX_PEER_LIST_SIZE): 100 -> 60, because 60 is well enough.
* src/HttpResponseCommand.cc
(handleDefaultEncoding): Added the cast to int32_t to itos.
This fixes compile error in Soralis 10.
To fix segfault in Metalink download:
* src/UrlRequestInfo.h
(filename): Removed.
(totalLength): Removed.
(setTotalLength): Removed.
(setFilename): Removed.
* src/MetalinkRequestInfo.cc
(execute): Do not set filename and totalLength to reqInfo.
Set chunk checksum to reqInfo if it is not null.
* src/HttpResponseCommand.cc
(executeInternal): Fixed filename in log.
(handleDefaultEncoding): Removed the call to initBitfield() and
markAllPiecesDone().
(handleOtherEncoding): Added HEAD method handling.
* src/FtpNegotiateCommand.cc
(executeInternal): Added SEQ_HEAD_OK handling.
(recvSize): In HEAD handling, set sequence to SEQ_HEAD_OK and
return false.
* src/FtpNegotiateCommand.h
(SEQ_HEAD_OK): New definition.
* src/SegmentMan.cc
(initBitfield): Delete bitfield.
(isChunkChecksumValidationReady): Fixed the condition.
* src/UrlRequestInfo.cc: Fixed so that Metalink and Torrent
download
works fine.
* src/Xml2MetalinkProcessor.h
(xpathExists): New function.
* src/Xml2MetalinkProcessor.cc
(xpathExists): New function.
Not to send HEAD request if filename and size are available in
Metalink
file:
* src/UrlRequestInfo.h
(filename): New variable.
(totalLength): New variable.
(setTotalLength): New function.
(setFilename): New function.
* src/MetalinkRequestInfo.cc
(execute): Set filename and size to UrlRequestInfo.
* src/MetalinkEntry.cc
(MetalinkEntry): Initialize size with 0.
* src/UrlRequestInfo.cc
(execute): Set filename and size to SegmentMan.
Not to download rest of the files after selected files are
downloaded
in BitTorrent:
* src/PieceStorage.h
(allDownloadFinished): New function.
* src/DefaultBtAnnounce.cc
(isCompleteAnnounceReady): Use allDownloadFinished instead of
downloadFinished.
(getAnnounceUrl): Use allDownloadFinished instead of
downloadFinished.
* src/DefaultPieceStorage.cc
(completePiece): Use allDownloadFinished instead of
downloadFinished.
Commented out the call to finishSelectiveDownloadingMode().
(downloadFinished): Call isFilteredAllBitSet() instead of
isAllBitSet().
(allDownloadFinished): New function.
* src/DefaultBtInteractive.cc
(addBitfieldMessageToQueue): Call allDownloadFinished() instead
of
downloadFinished().
(checkHave): Call allDownloadFinished() instead of
downloadFinished().
* src/TorrentDownloadEngine.cc
(onEndOfRun): Call allDownloadFinished() instead of
downloadFinished().
* src/BitfieldMan.h
(isFilteredAllBitSet): New function.
* src/ShareRatioSeedCriteria.h
(PieceStorage.h): New include.
(pieceStorage): New variable.
(evaluate):
btContext->getTotalLength() ->
pieceStorage->getCompletedLength()
* src/BitfieldMan.cc
(isFilteredAllBitSet): New function.
(isAllBitSet): Filter is not took into account.
Rename --force-truncate as --allow-overwrite:
* src/TorrentRequestInfo.cc
(execute): PREF_FORCE_TRUNCATE -> PREF_ALLOW_OVERWRITE
* src/main.cc
(showUsage): --force-truncate -> --allow-overwrite
* src/message.h
(EX_FILE_ALREADY_EXISTS): --force-truncate -> --allow-overwrite
* src/prefs.h
(PREF_FORCE_TRUNCATE): Removed.
(PREF_ALLOW_OVERWRITE): New definition.
* src/SegmentMan.cc
(shouldCancelDownloadForSafety): --force-truncate ->
--allow-overwrite
* src/MetalinkRequestInfo.cc
(execute): Queueing message are now logged in info level.
* src/common.h
(LONG_LONG_MAX): Removed.
(LONG_LONG_MIN): Removed.
* src/HttpResponseCommand.cc
(handleDefaultEncoding): LONG_LONG_MAX -> INT64_MAX
* src/FtpNegotiateCommand.cc
(recvSize): LONG_LONG_MAX -> INT64_MAX
* src/main.cc
(showUsage): Added --check-integiry and
--realtime-chunk-checksum
command-line option.
(main): Added --check-integiry and --realtime-chunk-checksum
command-line option.
--force-truncate -> --allow-overwrite
Set initial value of --check-integrity option to false.
Don't show usage when error occurs while persing command-line
options.
Removed deprecated --upload-limit option.
To add chunk checksum validation:
* src/MetalinkEntry.h
(MetalinkChunkChecksum.h): New include.
(chunkChecksum): New variable.
* src/Request.h
(method): New variable.
(setMethod): New function.
(getMethod): New function.
(METHOD_GET): New static constant.
(METHOD_HEAD): New static constant.
* src/Xml2MetalinkProcessor.h
(getPieceHash): New function.
* src/PieceStorage.h
(markAllPiecesDone): New function.
(checkIntegrity): New function.
* src/FileAllocator.h
(NullFileAllocationMonitor.h): New include.
(FileAllocator): Initialize fileAllocationMonitor with new
NullFileAllocationMonitor().
* src/MultiDiskAdaptor.h
(messageDigest.h): Remove include.
(ctx): Removed.
(hashUpdate): Added ctx.
(MultiDiskAdaptor): Removed ctx.
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/UrlRequestInfo.h
(HeadResult): New class.
(digestAlgo): New variable.
(chunkChecksumLength): New variable.
(chunkChecksums): New variable.
(getHeadResult): New function.
(UrlRequestInfo): Added digestAlgo, chunkChecksumLength.
(setDigestAlgo): New function.
(setChunkChecksumLength): New function.
(setChunkChecksums): New function.
* src/DefaultPieceStorage.cc
(DiskAdaptorWriter.h): New include.
(ChunkChecksumValidator.h): New include.
(markAllPiecesDone): New function.
(checkIntegrity): New function.
* src/DefaultBtContext.h
(getPieceHashes): New function.
* src/TorrentRequestInfo.cc
(execute): Try to validate chunk checksum if file already exists
and
.aria2 file doesn't there and user allows aria2 to overwrite it.
* src/messageDigest.h
(~MessageDigestContext): Added digestFree().
* src/MetalinkRequestInfo.cc
(execute): Set digestAlgo, chunkChecksum, chunkChecksums to
reqInfo.
* src/DiskAdaptor.h
(messageDigest.h): New include.
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/DownloadCommand.h
(PeerStat.h): New include.
(maxDownloadSpeedLimit): New variable.
(startupIdleTime): New variable.
(lowestDownloadSpeedLimit): New variable.
(peerStat): New variable.
(setMaxDownloadSpeedLimit): New function.
(setStartupIdleTime): New function.
(setLowestDownloadSPeedLimit): New function.
* src/BtContext.h
(getPieceHashes): New function.
* src/main.cc
(main): Set PREF_REALTIME_CHUNK_CHECKSUM and
PREF_CHECK_INTEGRITY
option to true for testing purpose.
* src/BtPieceMessage.cc
(checkPieceHash): Use messageDigest
* src/DownloadEngine.cc
(SetDescriptor): Removed.
(AccumulateActiveCommand): Removed.
(waitData): Rewritten.
(updateFdSet): Rewritten.
* src/MultiDiskAdaptor.cc
(hashUpdate): Added ctx.
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/BitfieldMan.h
(isBitRangeSet): New function.
(unsetBitRange): New function.
* src/ByteArrayDiskWriter.h
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/ConsoleDownloadEngine.cc
(calculateStatistics): If nspeed < 0 then set nspeed to 0.
* src/DiskWriter.h
(messageDigest.h): New include.
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/ChunkChecksumValidator.h: New class.
* src/DiskAdaptorWriter.h: New class.
* src/prefs.h
(PREF_REALTIME_CHUNK_CHECKSUM): New definition.
(PREF_CHECK_INTEGRITY): New definition.
* src/HttpResponseCommand.cc
(handleDefaultEncoding): Added method "HEAD" handling.
Removed the call to
e->segmentMan->shouldCancelDownloadForSafety().
(handleOtherEncoding):
Added the call to
e->segmentMan->shouldCancelDownloadForSafety().
(createHttpDownloadCommand): Set maxDownloadSpeedLimit,
startupIdleTime, lowestDownloadSpeedLimit to command.
* src/SegmentMan.h
(getSegmentEntryByIndex): New function.
(getSegmentEntryByCuid): New function.
(getSegmentEntryIteratorByCuid): New function.
(diskWriter): DiskWriter -> DiskWriterHandle
(pieceHashes): New variable.
(chunkHashLength): New variable.
(digestAlgo): New variable.
(FindPeerStat): Removed.
(getPeerStat): Rewritten.
(markAllPiecesDone): New function.
(checkIntegrity): New function.
(tryChunkChecksumValidation): New function.
(isChunkChecksumValidationReady): New function.
* src/BitfieldMan.cc
(BitfieldMan): Initialized bitfieldLength, blocks to 0.
(BitfieldMan): Initialized blockLength, totalLength,
bitfieldLength,
blocks to 0.
(isBitRangeSet): New function.
(unsetBitRange): New function.
* src/FtpNegotiateCommand.cc
(executeInternal): Set maxDownloadSpeedLimit,
startupIdleTime, lowestDownloadSpeedLimit to command.
(recvSize): Added method "HEAD" handling.
Removed the call to
e->segmentMan->shouldCancelDownloadForSafety().
* src/AbstractSingleDiskAdaptor.cc
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/AbstractSingleDiskAdaptor.h
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/Util.h
(indexRange): New function.
* src/MetalinkEntry.cc
(MetalinkEntry): Initialized chunkChecksum to 0.
* src/ShaVisitor.cc
(~ShaVisitor): Removed the call to ctx.digestFree().
* src/SegmentMan.cc
(ChunkChecksumValidator.h): New include.
(SegmentMan): Initialized chunkHashLength to 0. Initialized
digestAlgo
to DIGEST_ALGO_SHA1.
(~SegmentMan): Removed diskWriter.
(FindSegmentEntryByIndex): Removed.
(FindSegmentEntryByCuid): Removed.
(checkoutSegment): Rewritten.
(findSlowerSegmentEntry): Rewritten.
(getSegment): Rewritten.
(updateSegment): Rewritten.
(completeSegment): Rewritten.
(markAllPiecesDone): New function.
(checkIntegrity): New function.
(isChunkChecksumValidationReady): New function.
(tryChunkChecksumValidation): New function.
* src/Xml2MetalinkProcessor.cc
(getEntry): Get size and set it to entry.
Get chunk checksum and set it to entry.
(getPieceHash): New function.
* src/Util.cc
(sha1Sum): Removed ctx.digestFree()
(fileChecksum): Removed ctx.digestFree()
(indexRange): New function.
* src/Request.cc
(METHOD_GET): New variable.
(METHOD_HEAD): New variable.
(Request): Added method.
* src/UrlRequestInfo.cc
(FatalException.h): New include.
(message.h): New include.
(operator<<): Added operator<< for class HeadResult.
(getHeadResult): New function.
(execute): Get filename and size in separate download engine.
* src/ChunkChecksumValidator.cc: New class.
* src/DownloadCommand.cc:
(DownloadCommand): Added peerStat.
(executeInternal): Use maxDownloadSpeedLimit member instead of
getting
the value from Option.
The buffer size is now 16KB.
Use peerStat member instead of getting it from SegmentMan.
Use startupIdleTime member instead of gettingit from Option.
Added chunk checksum validation.
* src/AbstractDiskWriter.cc
(AbstractDiskWriter): Removed ctx.
(~AbstractDiskWriter): Removed ctx.digestFree()
(writeDataInternal): Returns the return value of write.
(readDataInternal): Returns the return value of read.
(sha1Sum): Renamed as messageDigest
(messageDigest): New function.
* src/AbstractDiwkWriter.h
(messageDigest.h): Removed include.
(ctx): Removed.
(sha1Sum): Renamed as messageDigest
(messageDigest): New function.
* src/DefaultPieceStorage.h
(markAllPiecesDone): New function.
(checkIntegrity): New function.
* src/NullFileAllocationMonitor.h: New class.
To decrease CPU usage in bittorrent download, calculation
results in
BitfieldMan were cached and realtime fetching PeerObject was
removed
with WeakHandle introduced. Option values are set to the objects
by setter before download begins.
* src/DefaultBtRequestFactory.cc: Use messageFactory member.
* src/DefaultBtRequestFactory.h
(dispatcher): BtMessageDispatcherHandle ->
BtMessageDispatcherWeakHandle.
(messageFactory): New variable.
(setBtMessageDispatcher): BtMessageDispatcherHandle ->
BtMessageDispatcherWeakHandle.
(setBtMessageFactory): New function.
* src/DefaultBtMessageDispatcher.cc:
(sendMessages): Use maxUploadSpeedLimit instead of fetching the
value
from Option.
(checkRequestSlotAndDoNecessaryThing): Use requestTimeout
instead of
feating the value from Option.
Use messageFactory member.
* src/PeerInteractionCommand.cc
(PeerInteractionCommand): Added maxDownloadSpeedLimit.
Add reverse dependencies to factory object.
Set maxUploadSpeedLimit and requestTimeout and messageFactory to
dispatcher.
Set messageFactory to receiver.
Set keepAliveInterval and maxDownloadSpeedLimit and
messageFactory to
btInteractive.
Set receiver to peerObject.
Set maxDownloadSpeedLimit to this.
(executeInternal): Use maxDownloadSpeedLimit member.
* src/BtChokeMessage.cc
(doReceivedAction): Use dispatcher, requestFactory member.
(onSendComplete): Use dispatcher member.
* src/PeerInteractionCommand.h
(maxDownloadSpeedLimit): New variable.
* src/DefaultBtMessageReceiver.h
(peerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(dispatcher):
BtMessageDispatcherHandle -> BtMessageDispatcherWeakHandle
(messageFactory): New variable.
(setPeerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(getPeerConnection): PeerConnectionHandle ->
PeerConnectionWeakHandle
(setDispatcher):
BtMessageDispatcherHandle -> BtMessageDispatcherWeakHandle
(setBtMessageFactory): New function.
* src/DefaultBtInteractive.cc
(initiateHandshake): Use messageFactory member.
(addBitfieldMessageToQueue): Use messageFactory member.
(addAllowedFastMessageToQueue): Use messageFactory member.
(decideChoking): Use messageFactory member.
(checkHave): Use messageFactory member.
(sendKeepAlive): Use keepAliveInterval, messageFactory member.
(receiveMessages): Use maxDownloadSpeedLimit member.
(decideInterest): Use messageFactory member.
* src/BtRequestMessage.cc
(doReceivedAction): Use messageFactory, dispatcher member.
(onQueued): Use dispatcher member.
* src/BtPieceMessage.cc
(doReceivedAction): Use dispatcher member.
(send): Use peerConnection member.
(onWrongPiece): Use requestFactory member.
(handleChokingEvent): Use messageFactory, dispatcher member.
(handleCancelSendingPieceEvent): Use messageFactory, dispatcher
member.
* src/BtMessageDispatcher.h
(BtMessageDispatcherWeakHandle): New type definition.
* src/SimpleBtMessage.cc
(send): Use peerConnection member.
* src/BtRejectMessage.cc
(doReceivedAction): Use dispatcher member.
* src/DefaultBtMessageDispatcher.h
(Option.h): Removed include.
(messageFactory): New variable.
(option): Removed.
(maxUploadSpeedLimit): New variable.
(requestTimeout): New variable.
(DefaultBtMessageDispatcher): Removed option.
Added maxUploadSpeedLimit, requestTimeout.
(setOption): Removed.
(getOption): Removed.
(setMaxUploadSpeedLimit): New function.
(setRequestTimeout): New function.
(setBtMessageFactory): New function.
* src/DefaultBtInteractive.h
(btMessageReceiver):
BtMessageReceiverHandle -> BtMessageReceiverWeakHandle
(dispatcher):
BtMessageDispatcherHandle -> BtMessageReceiverWeakHandle
(btRequestFactory):
BtRequestFactoryHandle -> BtRequestFactoryWeakHandle
(peerConnection):
PeerConnectionHandle -> PeerConnectionWeakHandle
(messageFactory): New variable.
(option): Removed.
(keepAliveInterval): New variable.
(maxDownloadSpeedLimit): New variable.
(DefaultBtInteractive): Added keepAliveInterval,
maxDownloadSpeedLimit.
(setBtMessageReceiver):
BtMessageReceiverHandle -> BtMessageReceiverWeakHandle
(setDispatcher):
BtMessageDispatcherHandle -> BtMessageReceiverWeakHandle
(setBtRequestFactory):
BtRequestFactoryHandle -> BtRequestFactoryWeakHandle
(setPeerConnection):
PeerConnectionHandle -> PeerConnectionWeakHandle
(setOption): Removed.
(setKeepAliveInterval): New function.
(setMaxDownloadSpeedLimit): New function.
(setBtMessageFactory): New function.
* src/BitfieldMan.h
(cachedNumMissingBlock): New variable.
(cachedNumFilteredBlock): New variable.
(cachedCompletedLength): New variable.
(cachedFilteredComletedLength): New variable.
(cachedFilteredTotalLength): New variable.
(countMissingBlockNow): New function.
(countFilteredBlockNow): New function.
(getFilteredTotalLengthNow): New function.
(getCompletedLengthNow): New function.
(getFilteredCompletedLengthNow): New function.
(updateCache): New function.
* src/AbstractBtMessage.h
(BtMessageDispatcher.h): New include.
(PeerConnection.h): New include.
(BtRequestFactory.h): New include
(BtMessageFactory.h): New include.
(dispatcher): New variable.
(messageFactory): New variable.
(peerConnection: New variable.
(setBtMessageDispatcher): New function.
(setPeerConnection): New function.
(setBtMessageFactory): New function.
(setBtRequestFactory): New function.
* src/DefaultBtMessageFactory.cc
(setCommonProperty): Set dispatcher, requestFactory, this,
peerConnection to msg.
* src/BtRegistry.h
(BT_MESSAGE_RECEIVER): New macro.
* src/PeerConnection.h
(PeerConnectionWeakHandle): New type definition.
* src/BtMessageFactory.h
(BtMessageFactoryWeakHandle): New type definition.
* src/BitfieldMan.cc
(BitfieldMan): Added cachedNumMissingBlock,
cachedNumFilteredBlock,
cachedCompletedLength, cachedFilteredComletedLength,
cachedFilteredTotalLength.
Call updateCache().
(countMissingBlock): Return cachedNumMissingBlock.
(countMissingBlockNow): New function.
(countBlock): Return cachedNumFilteredBlock if filterEnabled is
true.
(countFilteredBlockNow): New function.
(setBit): Call updateCache().
(unsetBit): Call updateCache().
(setBitfield): Call updateCache().
(clearAllBit): Call updateCache().
(setAllBit): Use setBitInternal instead of setBit.
Call updateCache().
(addFilter): Call updateCache().
(enableFilter): Call updateCache().
(disableFilter): Call updateCache().
(clearFilter): Call updateCache().
(getFilteredTotalLength): Return cachedFilteredTotalLength.
(getFilteredTotalLengthNow): New function.
(getCompletedLength): Return cachedCompletedLength.
(getCompletedLengthNow): New function.
(getFilteredCompletedLength): Return
cachedFilteredComletedLength.
(getFilteredCompletedLengthNow): New function.
(updateCache): New function.
* src/BtMessageReceiver.h
(BtMessageReceiverWeakHandle): New type definition.
* src/DefaultBtMessageReceiver.cc
(receiveHandshake): Use messageFactory member.
(sendHandshake): Use messageFactory member.
(receiveMessage): Use messageFactory member.
* src/DefaultBtMessageFactory.h
(dispatcher): New variable.
(requestFactory): New variable.
(peerConnection): New variablle.
(setBtMessageDispatcher): New function.
(setBtRequestFactory): New function.
(setPeerConnection): New function.
* src/SharedHandle.h
(RefCount): New class.
(WeakHandle): New class.
* src/PeerObject.h
(BtMessageReceiver.h): New include.
(PeerObject): Added btMessageReceiver.
(btMessageReceiver): New variable.
* src/Util.cc
(countBit): Simplified.
* src/BtCancelMessage.cc
(doReceivedAction): Use dispatcher member.
* src/BtRequestFactory.h
(BtRequestFactoryWeakHandle): New type definition.
* src/PeerStorage.h
(downloadSpeed): int -> uint32_t
(uploadSpeed): int -> uint32_t
(sessionDownloadLength): long long int -> uint64_t
(sessionUploadLength): long long int -> uint64_t
Rewritten a portion of bittorrent implementation:
* src/BtMessageValidator.h: New class.
* src/BtBitfieldMessageValidator.h: New class.
* src/BtHandshakeMessageValidator.h: New class.
* src/BtRequestMessageValidator.h: New class.
* src/BtSuggestPieceMessageValidator.h: New class.
* src/BtAllowedFastMessageValidator.h: New class.
* src/BtRejectMessageValidator.h: New class.
* src/BtCancelMessageValidator.h: New class.
* src/BtPieceMessageValidator.h: New class.
* src/BtHaveMessageValidator.h: New class.
* src/BtEventListener.h: New class.
* src/AbstractBtEventListener.h: New class.
* src/BtEvent.h: New class.
* src/BtChokingEvent.h: New class.
* src/BtChokedEvent.h: New class.
* src/BtCancelSendingPieceEvent.h: New class.
* src/BtAbortOutstandingRequestEvent.h: New class.
* src/Randomizer.h: New class.
* src/SimpleRandomizer.h: New class.
* src/BtMessage.h: New class.
* src/AbstractBtMessage.h: New class.
* src/SimpleBtMessage.h: New class.
* src/BtHaveMessage.h: New class.
* src/BtInterestedMessage.h: New class.
* src/BtAllowedFastMessage.h: New class.
* src/BtUnchokeMessage.h: New class.
* src/BtCancelMessage.h: New class.
* src/BtNotInterestedMessage.h: New class.
* src/BtChokeMessage.h: New class.
* src/BtHaveNoneMessage.h: New class.
* src/BtHandshakeMessage.h: New class.
* src/BtSuggestPieceMessage.h: New class.
* src/BtHaveMessage.h: New class.
* src/BtPieceMessage.h: New class.
* src/BtHaveAllMessage.h: New class.
* src/BtKeepAliveMessage.h: New class.
* src/BtPortMessage.h: New class.
* src/BtRejectMessage.h: New class.
* src/BtBitfieldMessage.h: New class.
* src/BtRequestMessage.h: New class.
* src/DefaultBtRequestFactory.h: New class.
* src/DefaultBtMessageReceiver.h: New class.
* src/BtInteractive.h: New class.
* src/BtMessageDispatcher.h: New class.
* src/DefaultBtMessageDispatcher.h: New class.
* src/DefaultBtInteractive.h: New class.
* src/BitfieldManFactory.h: New class.
* src/HandleRegistry.h: New class.
* src/BtMessageFactory.h: New class.
* src/BtMessageReceiver.h: New class.
* src/DefaultBtMessageFactory.h: New class.
* src/PeerObject.h: New class.
* src/BtRequestFactory.h: New class.
To know root cause of exception:
* src/Exception.h
(cause): New variable.
(Exception): Added a parameter.
(getMsg): Return const reference to msg.
(getCause): New function.
* src/DlRetryEx.h
(DlRetryEx): Added a parameter 'cause'.
Added an overloaded constructor.
(DlAbortEx): Added a parameter 'cause'.
Added an overloaded constructor.
* src/SimpleLogger.cc
(writeLog): Log nested exception messages recursively.
saved
to .aria2 file:
* src/DefaultPeerStorage.h
(removedPeerSessionDownloadLength): New variable.
(removedPeerSessionUploadLength): New variable.
* src/DefaultPeerStorage.cc
(DefaultPieceStorage): Added
removedPeerSessionDownloadLength(0),
removedPeerSessionUploadLength(0).
(calculateStat): Calculate the number of bytes
downloaded(uploaded)
through all peers, and then add
removedPeerSessionDownloadLength(
removedPeerSessionUploadLength) to it.
(deleteUnusedPeer): Add the number of bytes downloaded(uploaded)
from
(to) the peer to removedPeerSessionDownloadLength
(removedPeerSessionUploadLength).
Introduce new preference PREF_BT_TIMEOUT. This is the timeout
value
for BitTorrent download.
* src/PeerAbstractCommand.cc
(PeerAbstractCommand): PREF_TIMEOUT -> PREF_BT_TIMEOUT
* src/main.cc:
(timeoutSpecified): Removed.
(main): Set the initial value of PREF_BT_TIMEOUT to 180.
Removed timeoutSpecified. TODO: Add --bt-timeout command line
option.
* src/TorrentRequestInfo.cc
(timeoutSpecified): Removed.
(torrentHandler): Removed timeoutSpecified and the change of
timeout
value.
* src/prefs.h
(PREF_BT_TIMEOUT): New definition.
Delete unused variables.
* src/TorrentRequestInfo.cc
(requestInfo): Removed.
To add Metalink location option:
* src/MetalinkRequestInfo.cc
(execute): Call MetalinkEntry::setLocationPreference()
* src/main.cc
(showUsage): Added the help message for --metalink-location
option.
(main): Added --metalink-location option.
* src/prefs.h
(PREF_METALINK_LOCATION): New definition.
* src/MetalinkEntry.cc
(AddLocationPreference): New function object.
(setLocationPreference): New function.
* src/Xml2MetalinkProcessor.cc
(getResource): Set location attribute to MetalinkResource
To show URLs to download
* src/UrlRequestInfo.h
(printUrls): New function.
To add multiple <file> Metalink support:
* src/MetalinkEntry.h
(MetalinkResources): Removed.
(setLocationPreference): New function.
(MetalinkEntryHandle): New type definition.
(MetalinkEntries): New type definition.
* src/Xml2MetalinkProcessor.h
(getEntry): MetalinkEntry* -> MetalinkEntryHandle
(getResource): MetalinkResource* -> MetalinkResourceHandle
(parseFile): Metalinker* -> MetalinkerHandle
* src/UrlRequestInfo.h
(execute): RequestInfo* -> RequestInfos
* src/MetalinkRequestInfo.cc
(AccumulateNonP2PUrl): MetalinkResource* ->
MetalinkResourceHandle
(FindBitTorrentUrl): MetalinkResource* -> MetalinkResourceHandle
(execute): RequestInfo* -> RequestInfos
Added multiple <file> support. Print filename when it is queued.
* src/MetalinkRequestInfo.h
(execute): RequestInfo* -> RequestInfos
(getDownloadEngine): Removed.
* src/RequestInfo.h
(RequestInfoHandle): New type definition.
(RequestInfos): New type definition.
(execute): RequestInfo* -> RequestInfos
(getDownloadEngine): Removed.
* src/MetalinkResource.h
(MetalinkResourceHandle): New type definition.
(MetalinkResources): New type definition.
* src/MetalinkEntry.cc
(~MetalinkEntry): Removed the deletion of the elements of
resources,
because the element is now of type MetalinkResourceHandle.
(PrefOrder): MetalinkResource* -> MetalinkResourceHandle
(Supported): MetalinkResource* -> MetalinkResourceHandle
(dropUnsupportedResource): Removed the deletion of the elements
of
resources because the element is now of type
MetalinkResourceHandle.
* src/Xml2MetalinkProcessor.cc
(parseFile): Metalinker* -> MetalinkerHandle
MetalinkEntry* -> MetalinkEntryHandle
Removed try-catch block.
(getEntry): MetalinkEntry* -> MetalinkEntryHandle
MetalinkResource* -> MetalinkResourceHandle
Removed try-catch block.
(getResource): MetalinkResource* -> MetalinkResourceHandle
Free result by using xmlXPathFreeObject()
* src/Metalinker.cc
(~Metalinker): Removed the deletion of entries.
MetalinkEntry* -> MetalinkEntryHandle
(queryEntry): Add multiple <file> Metalink support.
* src/Metalinker.h
(MetalinkEntries): Removed.
(queryEntry): MetalinkEntry* -> MetalinkEntries
* src/MetalinkProcessor.h
(parseFile): Metalinker* -> MetalinkerHandle
Bug fixes:
* src/PeerChokeCommand.cc
(execute): cat01->cat02
* src/DefaultPieceStorage.cc
(DefaultPieceStorage): Added diskAdaptor(0)
* src/TrackerWatcherComand.cc:
(execute): Use btAnnounce->noMoreAnnounce()
to determin whether the function returns true or not.
* src/TrackerUpdateCommand.cc:
(execute): Use btAnnounce->noMoreAnnounce()
to determin whether the function returns true or not.
* src/FtpConnection.cc
(bulkReceiveResponse): Throw DlRetryEx if EOF got.
This is the fix of the busy loop bug.
* src/DownloadCommand.cc
(DownloadCommand): Reuse PeerStat. segmentMan->getPeerStat()
returns
cached PeerStat.
The value of "name" entry in torrent file is now set by
*DiskAdaptor::setTopDir(...) methods.
* src/MultiDiskAdaptor.h
(topDir): New variable.
(setTopDir): New function.
(getTopDir): New function.
* src/MultiDiskAdaptor.cc
(getFilePath): Concat storDir, "/" and topDir.
(mkdir): Use getFilePath() to get the directory path for output.
* src/DefaultPieceStorage.cc
(initStorage): Set the value of "name" entry to
MultiDiskAdaptor,
CopyDiskAdaptor.
* src/CopyDiskAdaptor.h
(topDir): New variable.
(setTopDir): New function.
(getTopDir): New function.
* src/CopyDiskAdaptor.cc
(fixFilename): Updated.
Misc
* src/UrlRequestInfo.h
(e): Removed.
(UrlRequestInfo): Removed e.
(getDownloadEngine): Removed.
* src/UrlRequestInfo.cc
(handler): Rewritten.
(printUrls): New function.
(execute): Call printUrls().
* src/HandshakeMessage.cc
(check): peerinteraction->getBtContext() -> btContext
* src/PeerInteraction.h
(getBtContext): Removed.
* src/TorrentRequestInfo.h
(execute): RequestInfo* -> RequestInfos
(getDownloadEngine): Removed.
* src/TorrentRequestInfo.cc
(haltRequested): Removed.
(btHaltRequested): New variable.
(torrentHandler): haltRequested -> btHaltRequested
(execute): RequestInfo* -> RequestInfos
* src/TorrentConsoleDownloadEngine.cc
(afterEachIteration): haltRequested -> btHaltRequested.
* src/ConsoleDownloadEngine.h
(initStatistics): Added virtual.
(calculateStatistics): Added virtual.
(onEndOfRun): Added virtual.
(afterEachIteration): Added virtual.
* src/ConsoleDownloadEngine.cc
(haltRequested): New variable.
(afterEachIteration): New function.
* src/main.cc
(requestInfo): Removed.
* src/SegmentMan.cc
(findSlowerSegmentEntry): Refactored.
To divide TorrentMan into 6 classes: BtContext, BtRuntime,
PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile
* src/TrackerWatcherComand.h: Made subclass of
BtContextAwareCommand.
* src/SeedCheckCommand.cc: Use pieceStorage, btRuntime
* src/PeerAbstractCommand.h: Made subclass of
BtContextAwareCommand.
* src/PeerAbstractCommand.cc: Use btRuntime.
* src/BtContextAwareCommand.h: New class.
* src/FileEntry.h: Added accessor methods for following
variables.
(path): Made private.
(length): Made private.
(offset): Made private.
(extracted): Made private.
(requested): Made private.
(FileEntries): New definition.
(FileEntryHandle): New definition.
* src/FileEntry.cc: New file.
* src/HaveEraseCommand.h: Made subclass of
BtContextAwareCommand.
* src/HaveEraseCommand.cc: Use btRuntime, pieceStorage.
* src/PeerChokeCommand.h: Made subclass of
BtContextAwareCommand.
* src/PeerChokeCommand.cc: Use btRuntime, peerStorage,
pieceStorage.
* src/PieceStorage.h: New file.
* src/PeerInteractionCommand.h: Use btContext.
* src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage,
btRuntime.
* src/DefaultBtProgressInfoFile.h: New file.
* src/DefaultBtProgressInfoFile.cc: New file.
* src/File.cc
(Util.h): New include.
(mkdirs): New function.
* src/MultiDiskAdaptor.h
(mkdir): New function.
* src/PeerListProcessor.h
(Peers): Removed.
* src/PeerInteraction.h
(torrentMan): Removed.
(btContext): New variable.
(peerStorage): New variable.
(pieceStorage): New variable.
(btAnnounce): New variable.
(getTorrentMan): Removed.
(getBtContext): New function.
* src/PeerInteraction.cc: Use btContext, peerStorage,
pieceStorage,
btAnnounce.
* src/HandshakeMessage.h
(TorrentMan.h): Removed.
* src/HandshakeMessage.cc: Use btContext.
* src/DefaultBtAnnounce.cc: New file.
* src/MultiDiskWriter.cc: Use the accessor methods of FileEntry.
* src/DefaultPieceStorage.cc: New file.
* src/DefaultBtContext.h: New file.
* src/TorrentRequestInfo.cc: Use btContext, pieceStorage.
Use the accessor methods of FileEntry.
* src/CookieBox.cc: Updated to use Util::slice().
* src/PieceMessage.cc: Use btContext, pieceStorage.
* src/common.h (SharedHandle.h): New include.
* src/PeerMessage.cc (PeerMessage): Added btContext,
peerStorage,
pieceStorage.
* src/TorrentAutoSaveCommand.h: Made subclass of
BtContextAwareCommand.
* src/DiskAdaptor.h
(topDir): Removed.
(getFileEntryFromPath): Changed the return type to
FileEntryHandle.
(setTopDir): Removed.
(getTopDir): Removed.
* src/BtContext.h: New file.
* src/DefaultPeerStorage.h: New file.
* src/PieceMessage.h (TorrentMan.h): Removed.
* src/RequestMessage.h (TorrentMan.h): Removed.
* src/TorrentDownloadEngine.h
(uploadLength): New variable.
(btContext): New variable.
(btRuntime): New variable.
(pieceStorage): New variable.
(peerStorage): New variable.
(btAnnounce): New variable.
(btProgressInfoFile): New variable.
(torrentMan): Removed.
(setBtContext): New function.
* src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime,
pieceStorage,
peerStorage, btAnnounce, btProgressInfoFile.
* src/Piece.h
(toString): New function.
(Pieces): New type definition.
* src/Peer.h
(active): New variable.
(Peer): Added active.
(activate): Set active to true.
(deactivate): Set active to false.
(isActive): New function.
(Peers): New type definition.
* src/DirectDiskAdaptor.cc
(getFilePath): Use the accessor methods of FileEntry.
* src/TorrentConsoleDownloadEngine.h
(afterEachIteration): New function.
* src/TorrentConsoleDownloadEngine.cc
(haltRequested): New variable.
(sendStatistics): Use pieceStorage, btRuntime.
(afterEachIteration): New function.
* src/AnnounceList: AnnounceTier->AnnounceTierHandle.
* src/Directry.h
(Directory): New function.
(DirectoryHandle): New type definition.
* src/BtProgressInfoFile.h: New file.
* src/RequestMessage.cc: Use pieceStorage.
* src/BtRuntime.h: New file.
* src/DefaultBtContext.cc: New file.
* src/BitfieldMan.h
(getCompletedLength): New function(private).
(getCompletedLength): New function.
(getFilteredCompletedLength): New function.
* src/BitfieldMan.h
(getCompletedLength): New function(private).
(getCompletedLength): New function.
(getFilteredCompletedLength): New function.
* src/MultiDiskAdaptor.cc
(mkdir): New function.
(openFile): Call mkdir().
(initAndOpenFile): Call mkdir().
* src/CancelMessage.h
(TorrentMan.h): Removed.
* src/RejectMessage.h
(TorrentMan.h): Removed.
* src/DownloadEngineFactory.cc
(DefaultPieceStorage.h): New include.
(DefaultPeerStorage.h): New include.
(DefaultBtAnnounce.h): New include.
(DefaultBtProgressInfoFile.h): New include.
(newTorrentConsoleEngine): Rewritten.
* src/ShareRatioSeedCriteria.h
(torrentMan): Removed.
(btContext): New variable.
(peerStorage): New variable.
(btRuntime): New variable.
(evaluate): Use btContext, btRuntime, peerStorage.
* src/AnnounceTier.h: New file.
* src/BtAnnounce.h: New file.
* src/BtRegistry.h: New file.
* src/PeerInitiateConnectionCommand.h: Added btContext.
* src/PeerConnection.h (TorrentMan.h): Removed.
* src/PeerMessageFactory.cc: Use btContext, pieceStorage.
* src/Util.h
(slice): Added an argument.
* src/Util.cc
(slice): Added an argument to control whether trim is made or
not.
* src/PeerStorage.h: New file.
* src/BtRegistry.cc: New file.
* src/TrackerUpdateCommand.h: Made subclass of
BtContextAwareCommand.
* src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry.
* src/MultiDiskWriter.h: FileEntry -> FileEntryHandle
* src/PeerListenCommand.cc: Use btRuntime, peerStorage,
btContext.
* src/TorrentRequestInfo.h
(e): Removed.
(showFileEntry): Added an argument.
(getDownloadEngine): Return 0.
* src/DefaultBtAnnounce.h: New file.
* src/TorrentAutoSaveCommand.cc: Use btRuntime,
btProgressInfoFile.
* src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce,
* src/PeerMessageFactory.h
(btContext): New variable.
(pieceStorage): New variable.
* src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage,
btContext,
btAnnounce.
* src/DiskAdaptor.cc
(DiskAdaptor): Removed topDir.
(~DiskAdaptor): Removed topDir.
* src/PeerListenCommand.h: Made subclass of
BtContextAwareCommand.
* src/SeedCheckCommand.h: Made subclass of
BtContextAwareCommand.
* src/File.h (mkdirs): New function.
* src/DefaultPeerStorage): New file.
* src/DownloadEngineFactory.h
(newTorrentConsoleEngine): Use btContext.
* src/BtContextAwareCommand.cc: New file.
* src/PeerInitiateConnectionCommand.cc: Use btRuntime,
peerStorage.
* src/PeerMessage.h
(btContext): New variable.
(peerStorage): New variable.
(pieceStorage): New variable.
(setBtContext): New function.
* src/Directry.cc
(Directory): New function.
(createDir): Do nothing if name.size() == 0.
* src/AnnounceList.h
(AnnounceTier): Removed.
(AnnounceTiers): Removed.
* src/DefaultPieceStorage.h: New file.
* src/Piece.cc (toString): New function.
To fix typo:
* src/main.cc (showVersion): Fixed typo.
To fix compile warning:
* src/DelegatingPeerListProcessor.cc
(canHandle): Added "return false".
To simplify TrackerWatherCommand, TrackerUpdateCommand and
make the process of announce request testable.
* src/TrackerWatcherCommand.h
(TimeA2.h): Removed.
(interval): Removed.
(checkPoint): Removed.
(createRequestCommand): Added an argument 'url'.
(TrackerWatherCommand): Removed interval.
(createCommand): New function.
* src/DownloadEngineFactory.cc
(newTorrentConsoleEngine): Updated according to the changes in
TrackerWatherCommand.
* src/TorrentMan.cc
(DelegatingPeerListProcessor.h): New includes.
(TorrentMan): Added the initialization of announceInterval.
(isStoppedAnnounceReady): New function.
(isCompletedAnnounceReady): New function.
(isDefaultAnnounceReady): New function.
(isAnnounceReady): New function.
(getAnnounceUrl): New function.
(announceStart): New function.
(announceFailure): New function.
(announceSuccess): New function.
(isAllAnnounceFailed): New function.
(resetAnnounce): New function.
(processAnnounceResponse): New function.
(needMorePeerConnection): New function.
(noMoreAnnounce): New function.
* src/TrackerUpdateCommand.h
(getTrackerResponse): int->size_t
* src/TorrentMan.h
(isStoppedAnnounceReady): New function.
(isCompletedAnnounceReady): New function.
(isDefaultAnnounceReady): New function.
(announceInterval): New variable.
(isAnnounceReady): New function.
(getAnnounceUrl): New function.
(announceStart): New function.
(announceFailure): New function.
(announceSuccess): New function.
(isAllAnnounceFailed): New function.
(resetAnnounce): New function.
(processAnnounceResponse): New function.
(needMorePeerConnection): New function.
(noMoreAnnounce): New function.
* src/TrackerWatcherCommand.cc
(TrackerWatherCommand): Removed interval and checkPoint.
(execute): Rewritten.
(createCommand): New function.
(createRequestCommand): Rewritten.
* src/TrackerUpdateCommand.cc
(MetaFileUtil.h): Removed.
(DelegatingPeerListProcessor.h): Removed.
(getTrackerResponse): int->size_t. Use torrentMan's new
functions.
To add timeout to async name resolution:
* src/AbstractCommand.h
(nameResolveFinished): New function. This is not elegant way. It needs
to be more refined.
(nameResolverCheck): New variable.
* src/AbstractCommand.cc
(AbstractCommand): Added nameResolverCheck.
(execute): Added the check whether the name resolution has finished.
(setNameResolverCheck): Set nameResolverCheck to true.
(disableNameResolverCheck): Set nameResolverCheck to false.
(nameResolverFinished): New function.
* src/FtpInitiateConnectionCommand.h
(nameResolverFinished): New function.
* src/HttpInitiateConnectionCommand.h
(nameResolverFinished): New function.
To add the support for a non-compact response from a tracker:
* src/PeerListProcessor.h: New class.
* src/DefaultPeerListProcessor.h: New class.
* src/DefaultPeerListProcessor.cc: New class.
* src/CompactPeerListProcessor.h: New class.
* src/CompactPeerListProcessor.cc: New class.
* src/DelegatingPeerListProcessor.h: New class.
* src/DelegatingPeerListProcessor.cc: New class.
* src/TorrentMan.cc
(addPeer): New function(overload).
(addPeer): Delete unused peers only when new peer is added.
* src/TorrentMan.h
(PeerListProcessor.h): Included.
(Peers): Removed.
(addPeer): New function(overload).
* src/TrackerUpdateCommand.cc
(netinet/in.h): Removed.
(DelegatingPeerListProcessor.h): Included.
(execute): Updated to use DelegatingPeerListProcessor.
To fix the memory leak in TorrentMan::peers:
* src/PeerAbstractCommand.cc
(onAbort): Added peer->resetStatus().
* src/Peer.h
(resetStatus): Made public.
To improve the precision of the speed calculation:
* src/SpeedCalc.h
(nextInterval): New variable.
* src/SpeedCalc.cc
(reset): Added nextInterval.
(isIntervalOver): Use nextInterval instead of CHANGE_INTERVAL_SEC.
(changeSw): Set nextInterval to 15 seconds relative to the current
instant time.
* src/main.cc
(showVersion): Updated.
(PREF_MAX_SPEED_LIMIT): Renamed as PREF_MAX_DOWNLOAD_LIMIT.
(PREF_UPLOAD_LIMIT): Renamed as PREF_MAX_UPLOAD_LIMIT.
* src/PeerInteractionCommand.cc
(PeerInteractionCommand): Use PREF_MAX_UPLOAD_LIMIT.
(receiveMessages): Use PREF_MAX_DOWNLOAD_LIMIT.
* src/PeerInteraction.cc
(sendMessages): Use PREF_MAX_UPLOAD_LIMIT.
* src/main.cc
(showUsage): Updated the description of "--lowest-speed-limit"
option.
Added the description of "--max-download-limit" option.
Removed the description of "--upload-limit" option.
Added the description of "--max-upload-limit" option.
(main): Use PREF_MAX_UPLOAD_LIMIT, PREF_MAX_DOWNLOAD_LIMIT.
Added "--max-download-limit" option and "--max-upload-limit"
option.
Added the warning message if "--upload-limit" option is used.
* src/DownloadCommand.cc
(executeInternal): Use PREF_MAX_DOWNLOAD_LIMIT.
(optUnchokingPeer): Updated according to the changes in Peer.
(ResetDelta): Removed.
(UploadFaster): Updated according to the changes in Peer.
(DownloadFaster): Updated according to the changes in Peer.
(execute): I clarify the meaning of "upload" and "download"
here.
"upload" means the transfer from localhost to remote host.
"download" means the transfer from remote host to localhost.
Based on this rule, I swapped orderByUploadRate and
orderByDownloadRate.
* src/PeerInteractionCommand.cc
(PeerInteraction): Removed peerInteraction->setUploadLImit().
(executeInternal): Removed the argument of
peerInteraction->sendMessages().
(receiveMessages): Rewritten download speed limit.
(sendKeepAlive): Removed peerInteraction->sendMessages().
* src/HttpResponseCommand.cc
(handleDefaultEncoding): If file size is unknown in torrent
request,
do not call segmentMan->initBitfield() here.
Disabled persistent connection feature in torrent request.
* src/UrlRequestInfo.h
(UrlRequestInfo): Removed const qualifier from option.
* src/TorrentMan.h
(TransferStat): New class.
(deltaDownloadLength): Removed.
(deltaUploadLength): Removed.
(addDeltaDownloadLength): Removed.
(getDeltaDownloadLength): Removed.
(resetDeltaDownloadLength): Removed.
(addDeltaUploadLength): Removed.
(getDeltaUploadLength): Removed.
(resetDeltaUploadLength): Removed.
(addActivePeer): Added peer->activate().
(deleteActivePeer): Added peer->deactivate().
(calculateStat): New function.
* src/TorrentMan.cc
(TorrentMan): Removed deltaDownloadLength and deltaUploadLength.
(calculateStat): New function.
* src/PeerInteraction.h
(uploadLimit): Removed.
(option): New variable.
(setUploadLimit): Removed.
(getUploadSpeed): Removed.
(sendMessages): Removed the argument "currentUploadSpeed".
* src/PeerInteraction.cc
(prefs.h): Included.
(PeerInteraction): Removed uploadLimit. Added option.
(sendMessages): Rewritten upload speed limit.
(sendHandshake): Removed the argument from sendMessages().
(sendBitfield): Removed the argument from sendMessages().
* src/PeerAbstractCommand.cc
(execute): Commented out the portion of upload limit.
(onAbort): Removed peer->resetStatus().
* src/TorrentRequestInfo.cc
(timeoutSpecified): Declared extern.
(execute): Set timeout to 180 if timeout is not specified by.
command-line.
* src/PieceMessage.cc
(receivedAction): Added peer->updateDownloadLength().
Removed peer->addPeerUpload().
Removed torrentMan->addDeltaDownloadLength().
(send): Added peer->updateUploadLength().
Removed peer->addPeerDownload().
Removed torrentMan->addDeltaUploadLength().
* src/main.cc
(timeoutSpecified): New variable.
(main): Set timeoutSpecified to false.
If the command-line option "--upload-limit" is specified, then
timeoutSpecified is set to true. This option will remain in the
next
release, but be deprecated in the future release.
* src/TorrentRequestInfo.h
(TorrentRequestInfo): Removed const qualifier from op.
* src/PeerStat.h
(uploadSpeed): New variable.
(PeerStat): Added default value to cuid.
(calculateUploadSpeed): New function.
(updateUploadLength): New function.
(getMaxUploadSpeed): New function.
(getAvgUploadSpeed): New function.
(reset): Added uploadSpeed. Set status to IDLE.
* src/TorrentDownloadEngine.h
(cp): Declared as Time.
(sessionDownloadLengthArray): Removed.
(sessionUploadLengthArray): Removed.
(currentCp): Removed.
(lastCalcStat): New variable
(lastElapsed): Removed.
(sessionDownloadLength): Removed.
(calculateStat): New function.
* src/TorrentDownloadEngine.cc
(initStatistics): Removed lastElapsed, cp[],
sessionDownloadLengthArray[], sessionUploadLengthArray[],
currentCp, sessionDownloadLength.
Added cp.reset() and lastCalcStat.reset().
(calculateSpeed): Changed the name of the argument.
(calculateStatistics): Rewritten.
(calculateStat): New function.
* src/Peer.h
(PeerStat.h): Included.
(peerUpload): Removed.
(peerDownload): Removed.
(peerStat): New variable.
(sessionUploadLength): New variable.
(sessionDownloadLength): New variable.
(deltaUpload): Removed.
(deltaDownload): Removed.
(resetStatus): Made private.
(Peer): Added sessionUploadLength, sessionDownloadLength.
Removed peerUpload, peerDownload.
(updateUploadLength): New function.
(addDeltaUpload): Removed.
(updateDownloadLength): New function.
(resetDeltaUpload): Removed.
(getDeltaUpload): Removed.
(addDeltaDownload): Removed.
(calculateUploadSpeed): New function.
(resetDeltaDownload): Removed.
(getDeltaDownload): Removed.
(calculateDownloadSpeed): New function.
(getSessionUploadLength): New function.
(getSessionDownloadLength): New function.
(activate): New function.
(deactivate): New function.
(addPeerUpload): Removed.
(setPeerUpload): Removed.
(getPeerUpload): Removed.
(addPeerDownload): Removed.
(setPeerDownload): Removed.
(getPeerDownload): Removed.
* src/Peer.cc
(resetStatus): Removed resetDeltaUpload() and
resetDeltaDownload().
* src/MetalinkRequestInfo.h
(MetalinkRequestInfo): Removed const qualifier from op.
* src/RequestInfo.h
(op): Removed const qualifier.
(RequestInfo): Removed const qualifier from op.
* 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.