Commit Graph

1291 Commits (38e9f1febcdf5e7f74a1916ddb63a7c95a372ad4)

Author SHA1 Message Date
Tatsuhiro Tsujikawa ccdd5b31a3 2007-06-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/FileAllocationCommand.cc: Derived from RealtimeCommand.
	* src/CheckIntegrityCommand.cc: Derived from RealtimeCommand.
	
	* src/MetalinkEntry.h
	(checksum): Changed to ChecksumHandle
	* src/MetalinkRequestInfo.cc
	(checksum): Changed to ChecksumHandle

	* src/File.cc
	(mkdirs): OPEN_MODE -> DIR_OPEN_MODE
	* src/common.h
	(DIR_OPEN_MODE): New definition

	* src/RequestGroup.cc
	(prepareForNextAction): Added an argument.

	* src/message.h
	(MSG_GOOD_CHECKSUM): New definition
	(MSG_BAD_CHECKSUM): New definition

	* src/HttpResponseCommand.cc
	(handleDefaultEncoding): Continue download sequence in new
	non-segmented download.

	* src/FileAllocationEntry.h
	(_nextDownloadCommand): New variable.

	* src/DownloadCommand.cc
	(prepareForNextSegment): Create ChecksumCommand if checksum is
	available.	

	* src/RealtimeCommand.h, src/RealtimeCommand.cc: New class.

	* src/IteratableChecksumValidator.h,
	src/IteratableChecksumValidator.cc: New class.

	* src/ChecksumCommand.h, src/ChecksumCommand.cc: New class.
2007-05-31 15:56:20 +00:00
Tatsuhiro Tsujikawa 8eeeac7192 2007-05-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Change file mode to 666:
	* src/common.h (OPEN_MODE): New definition.
	* src/File.cc
	* src/Util.cc
	* src/Directry.cc
	* src/AbstractDiskWriter.cc

	Change the level of log message "download aborted" to debug:
	* src/PeerAbstractCommand.cc (execute)
	
	* src/RequestGroup.h (RequestGroup): Initialized 
_hintTotalLength to 0.

	* src/TrackerWatcherCommand.cc
	(createCommand): Sleep some seconds after request failed.
	If tracker request fails more than value of 
PREF_TRACKER_MAX_TRIES,
	then abort tracker request.
2007-05-22 16:55:56 +00:00
Tatsuhiro Tsujikawa ad7078db28 Use CUIDCounter instead of BtRuntime::getNewCuid():
* src/ActivePeerConnectionCommand.cc
	* src/PeerInteractionCommand.cc
	* src/BtRuntime.h
	(cuidCounter): Removed.
	(getNewCuid): Removed.
	* src/DownloadEngineFactory.cc
	* src/PeerListenCommand.cc
	* src/TrackerUpdateCommand.cc
	* src/PeerInitiateConnectionCommand.cc
	Use CUIDCounter instead of BtRuntime::getNewCuid():
	* src/ActivePeerConnectionCommand.cc
	* src/PeerInteractionCommand.cc
	* src/BtRuntime.h
	(cuidCounter): Removed.
	(getNewCuid): Removed.
	* src/DownloadEngineFactory.cc
	* src/PeerListenCommand.cc
	* src/TrackerUpdateCommand.cc
	* src/PeerInitiateConnectionCommand.cc
2007-05-20 15:22:50 +00:00
Tatsuhiro Tsujikawa f3995b1f7e 2007-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Added the simultaneous download feature.
	* src/main.cc: Print "Exception caught: " when exception is 
caught.
2007-05-20 14:27:28 +00:00
Tatsuhiro Tsujikawa 079d2844ec New files 2007-05-20 13:57:56 +00:00
Tatsuhiro Tsujikawa eaf2d53a91 2007-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Added the simultaneous download feature.
2007-05-20 13:51:52 +00:00
Tatsuhiro Tsujikawa dd37b7be0a 2007-04-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/PeerAbstractCommand.cc
	(onAbort): Call PeerStorage::returnPeer()
	* src/DefaultPeerStorage.h, src/DefaultPeerStorage.cc
	(incomingPeers): New variable.
	(addIncomingPeer): New function.
	(returnPeer): New function.
	(onErasingPeer): New function.
	(addPeer): push_back -> push_front
	(getActivePeers): Rewritten.
	(calculateStat): Rewritten.
	* src/PeerStorage.h
	(TransferStat::copy): New function.
	(TransferStat::TransferStat): New function.
	(TransferStat::operator=): New function.
	(addIncomingPeer): New function.
	(returnPeer): New function.
	* src/PeerListenCommand.cc
	(execute): Use PeerStorage::addIncomingPeer() instead of
	Peer::addPeer().
2007-04-05 16:47:59 +00:00
Tatsuhiro Tsujikawa f030408d8e 2007-04-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Connect to a peer actively when download speed is lower than 
specified
	speed in torrent download:
	* src/ActivePeerConnectionCommand.h: New class.
2007-04-03 10:52:31 +00:00
Tatsuhiro Tsujikawa 5377be3680 Updated to 0.10.2+1 2007-03-29 11:31:15 +00:00
Tatsuhiro Tsujikawa 608009ec06 2007-03-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/HttpRequest.cc (createRequest): url-encode user-agent

	* src/main.cc: Fixed the bug that prevents download if .netrc
	doesn't exist.
2007-03-29 11:29:45 +00:00
Tatsuhiro Tsujikawa 4016aa3948 In http request, suppress port number in http request header if
port
	is 80 or 443:
	* src/HttpRequest.cc (getHostText): Suppress port number in http
	request header if port is 80 or 443.
	(createProxyRequest): Allways send port number.
2007-03-28 16:26:27 +00:00
Tatsuhiro Tsujikawa fe9c638735 Update doc about configuration file. 2007-03-28 16:13:36 +00:00
Tatsuhiro Tsujikawa e78c8b0a03 Fixed compilation errors 2007-03-28 16:11:04 +00:00
Tatsuhiro Tsujikawa 24d199632b 2007-03-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To cache resolved hostname:
	* src/AbstractCommand.h, src/AbstractCommand.cc
	(resolveHostname): Put outside #ifdef ENABLE_ASYNC_DNS clause.
	Added dns cache.
	* src/FtpInitiateConnectionCommand.cc
	(executeInternal): Removed #ifdef ENABLE_ASYNC_DNS.
	* src/NameResolver.h, src/NameResolver.cc: Added synchronized
	NameResolver working without ares.
	* src/TorrentRequestInfo.cc
	(execute): Don't cache dns in torrent download.
	* src/HttpInitiateConnectionCommand.cc
	(executeInternal): Removed #ifdef ENABLE_ASYNC_DNS
	* src/DNSCache.h: New class.
	* src/UrlRequestInfo.cc
	(execute): Use dns cache
2007-03-28 15:08:22 +00:00
Tatsuhiro Tsujikawa 843e641483 Fixed typo 2007-03-27 16:47:41 +00:00
Tatsuhiro Tsujikawa a1b57c5755 2007-03-27 16:38:11 +00:00
Tatsuhiro Tsujikawa 6e6ba30c60 2007-03-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the command-line option which disables netrc support:
	* src/OptionHandlerFactory.cc
	(createOptionHandlers): Added PREF_NO_NETRC.
	* src/main.cc: Added -n option.
	* src/prefs.h (PREF_NO_NETRC): New definition.
	* src/RequestFactory.cc: Do not use netrc in ftp if 
PREF_NO_NETRC is
	V_TRUE.
	Note that netrc is not used in http, http proxy even if 
PREF_NO_NETRC
	is V_FALSE. This may get configurable in the future release.
	
	To clear peer's error status by time basis:
	* src/PeerAbstractCommand.cc
	(onAbort): Call Peer::startBadCondition().
	* src/Peer.h, src/Peer.cc
	(error): Removed.
	(_badConditionStartTime): New variable.
	(_badConditionInterval): New variable. Initialized to 10 
seconds.
	(startBadCondition): New function.
	(isGood): New function.
	* src/DefaultPeerStorage.cc
	(addPeer): Use Peer::isGood().
	(FindFinePeer): Use Peer::isGood().

	Always include port number in http request header:
	* src/HttpRequest.cc (getHostText): Always include port number 
in
	http request header.
2007-03-27 16:16:44 +00:00
Tatsuhiro Tsujikawa 9b73454b07 2007-03-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To the ability to read options from a config file:
	* src/main.cc: Command-line parameter validation is delegated to
	OptionHandler class.
	* src/OptionHandlerFactory.h, src/OptionHandlerFactory.cc: New 
class.
	* src/Option.h, src/Option.cc (clear): New function.
	* src/OptionParser.h, src/OptionParser.cc: New class.
	* src/OptionHandler.h: New class.
	* src/NameMatchOptionHandler.h: New class.
	* src/OptionHandlerImpl.h: New classes.
	* src/prefs.h: '_' -> '-'
	(FTP_PASV_ENABLED): Renamed to FTP_PASV.
	(FTP_PASV): New definition.
	* src/Util.h, src/Util.cc (getRealSize): New function.
	
	To disable netrc support if .netrc file does not have correct
	permissions:
	* src/File.h, src/File.cc (mode): New function.

	To prevent confidential information to be logged:
	* src/HttpConnection.h, src/HttpConnection.cc
	(eraseConfidentialInfo): New function.
	(sendRequest): Call eraseConfidentialInfo().
	(sendProxyRequest): Call eraseConfidentialInfo().
	* src/main.cc: Validate permissions of .netrc file.
	
	To add --user-agent command-line option:
	* src/main.cc: Added new command line option: --user-agent
	* src/prefs.h (PREF_USER_AGENT): New definition.
	* src/HttpRequestCommand.cc (executeInternal): Set user-agent 
option
	parameter to HttpRequest object.
	
	Marged the patches from Dan Fandrich.
2007-03-26 12:16:57 +00:00
Tatsuhiro Tsujikawa 228ed66f73 2007-03-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use filename and size from Metalink file instead of sending HEAD
	request:
	* src/UrlRequestInfo.h
	(_filename): New variable.
	(_totalLength): New variable.
	(setTotalLength): New variable.
	(setFilename): New variable.
	* src/MetalinkRequestInfo.cc
	(execute): Set filename and size to UrlRequestInfo
	* src/UrlRequestInfo.cc
	(execute): Use filename and size from Metalink instead of seding
	HEAD request to servers.
2007-03-25 03:44:47 +00:00
Tatsuhiro Tsujikawa 460c874e26 Added the usage message for -c command-line option. 2007-03-24 15:46:41 +00:00
Tatsuhiro Tsujikawa e36fadac88 Pass totalLength to DiskWriter::openExistingFile 2007-03-24 15:32:40 +00:00
Tatsuhiro Tsujikawa f9ac6bb6fd Do not print URLs to stdout:
* src/UrlRequestInfo.cc
2007-03-24 15:15:51 +00:00
Tatsuhiro Tsujikawa a37aaa9c0c 2007-03-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the ability to resume downloading a partially downloaded 
file
	which is downloaded from the beginning:
	* src/FileAllocator.h: Made abstract class. New 
DefaultFileAllocator
	takes this role.
	* src/main.cc: Added -c option.
	* src/BitfieldMan.h, src/BitfieldMan.cc (setBitRange): New 
function.
	* src/DiskWriter.h (openExistingFile): Added totalLength 
argument.
	* src/prefs.h (PREF_CONTINUE): New definition.
	* src/SegmentMan.h, src/SegmentMan.cc (markPieceDone): New 
function.
	* src/DefaultDiskWriter.cc
	(createNewDiskWriter): Add GlowFileAllocator to the new object.
	* src/AbstractDiskWriter.h
	(glowFileAllocator): New variable.
	* src/AbstractDiskWriter.cc
	(openExistingFile): Now preallocate file space from the end of 
the
	existing file if totalLength argument is specified and grater 
than 0.
	* src/UrlRequestInfo.cc: If -c option is specified and the file
	to download exists in local, continue the download of the file.
	--allow-overwrite=true is assumed in this context.
	* src/DefaultFileAllocator.h, src/DefaultFileAllocator.cc: New 
class.
	* src/GlowFileAllocator.h, src/GlowFileAllocator.cc: New class.

	Throw exception if --check-integrity=true is specified but chunk
	checksums are not provided:
	* src/UrlRequestInfo.cc
2007-03-24 14:32:49 +00:00
Tatsuhiro Tsujikawa 5649cf6cda 2007-03-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* 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.
2007-03-21 10:19:23 +00:00
Tatsuhiro Tsujikawa 0f514b0db1 Added operator<< 2007-03-19 17:04:15 +00:00
Tatsuhiro Tsujikawa 4c00118409 Removed. 2007-03-19 17:03:15 +00:00
Tatsuhiro Tsujikawa 7ff627079f 2007-03-19 Tatsuhiro Tsujikawa <tujikawa at valkyrie dot rednoah com>
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.
2007-03-18 15:42:34 +00:00
Tatsuhiro Tsujikawa 58d4dde223 authenticatable -> authenticator 2007-03-18 12:37:35 +00:00
Tatsuhiro Tsujikawa 113c8fac7f 2007-03-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
2007-03-16 14:21:29 +00:00
Tatsuhiro Tsujikawa 11907c175d 2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
2007-03-15 15:07:18 +00:00
Tatsuhiro Tsujikawa ba7f9f7657 2007-03-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* 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.
2007-03-05 12:31:57 +00:00
Tatsuhiro Tsujikawa cc24f7cdf8 To fix static initialization order problem:
* src/BitfieldManFactory.h
	(defaultRandomizer): Removed.
	(factory): New variable.
	(getNewFactory): Removed.
	(getFactoryInstance): New function.
	(setDefaultRandomizer): Rewritten.
	(getDefaultRandomizer): Rewritten.
	* src/BitfieldManFactory.cc
	(defaultRandomizer): Removed.
	(factory): Initialized to 0.
	(BitfieldManFactory): Initialized randomizer to 0.
	* src/DefaultPieceStorage.cc
	(DefaultPieceStorage): getNewFactory() -> getFactoryInstance()
	* src/Peer.cc
	(Peer): getNewFactory() -> getFactoryInstance()
	* src/SegmentMan.cc
	(initBitfield): getNewFactory() -> getFactoryInstance()
	* src/Piece.cc
	(Piece): getNewFactory() -> getFactoryInstance()
2007-02-12 12:05:55 +00:00
Tatsuhiro Tsujikawa aa1730d1f3 * Release 0.10.1 2007-02-06 15:54:39 +00:00
Tatsuhiro Tsujikawa 5b2f8f036e 2007-02-06 Tatsuhiro Tsujikawa <tujikawa dot rednoah dot com>
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.
2007-02-06 14:49:22 +00:00
Tatsuhiro Tsujikawa a4e7bd7ec4 2007-02-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
2007-02-03 04:17:22 +00:00
Tatsuhiro Tsujikawa 77a05c00b1 2007-01-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
2007-01-29 16:46:48 +00:00
Tatsuhiro Tsujikawa 2ab41c4f17 2007-01-28 15:11:00 +00:00
Tatsuhiro Tsujikawa e0639ab292 2007-01-28 14:44:16 +00:00
Tatsuhiro Tsujikawa cd91e2ea4f 2007-01-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* 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.
2007-01-28 14:18:35 +00:00
Tatsuhiro Tsujikawa cd9e35bc63 2007-01-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/message.h: Added EX_INVALID_PAYLOAD_SIZE and
	EX_INVALID_BT_MESSAGE_ID. Following source files affected.
	* src/BtAllowedFastMessage.cc:
	* src/BtBitfieldMessage.cc
	* src/BtCancelMessage.cc
	* src/BtChokeMessage.cc
	* src/BtHaveAllMessage.cc
	* src/BtHaveMessage.cc
	* src/BtHaveNoneMessage.cc
	* src/BtInterestedMessage.cc
	* src/BtNotInterestedMessage.cc
	* src/BtPieceMessage.cc
	* src/BtPortMessage.cc
	* src/BtRejectMessage.cc
	* src/BtRequestMessage.cc
	* src/BtSuggestPieceMessage.cc
	* src/BtUnchokeMessage.cc

	* src/message.h: Added EX_INVALID_CHUNK_CHECKSUM. Following 
source
	files are affected.
	* src/ChunkChecksumValidator.cc
	* src/SegmentMan.cc
2007-01-25 16:47:29 +00:00
Tatsuhiro Tsujikawa 139f46332e 2007-01-24 15:56:34 +00:00
Tatsuhiro Tsujikawa ea6d9493c8 2007-01-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
2007-01-24 15:55:34 +00:00
Tatsuhiro Tsujikawa a1df7a762e 2007-01-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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
2007-01-16 15:20:26 +00:00
Tatsuhiro Tsujikawa d28e6aca15 2007-01-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add RecoverableException, FatalException:
	
	* src/AbstractCommand.cc
	(onAbort): Exception -> RecoverableException
	* src/PeerAbstractCommand.h
	(RecoverableException.h): New include.
	(onAbort): Exception -> RecoverableException.
	* src/PeerInteractionCommand.cc
	(onAbort): Exception -> RecoverableException.
	* src/PeerAbstractCommand.cc
	(execute): Exception -> RecoverableException.
	(onAbort): Exception -> RecoverableException.
	* src/TorrentRequestInfo.cc
	(execute): Exception -> RecoverableException.
	* src/MetalinkRequestInfo.cc
	(execute): Exception -> RecoverableException.
	* src/MetaFileUtil.cc: RecoverableException.
	* src/AbstractCommand.h
	(onAbort): Exception -> RecoverableException.
	* src/DlRetryEx.h: Exception -> RecoverableException.
	* src/DlAbortEx.h: Exception -> RecoverableException.
	* src/PeerListenCommand.cc: Exception -> RecoverableException.
	* src/Util.cc: Exception -> RecoverableException.
	* src/DefauldDiskWriter.cc: Exception -> RecoverableException.
	* src/TrackerUpdateCommand.cc: Exception -> 
RecoverableException.
	* src/UrlRequestInfo.cc: Exception -> RecoverableException.
	
	To make ID static const int

	* src/BtInterestedMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtPieceMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtChokeMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtHaveAllMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtKeepAliveMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtHandshakeMessage.h
	(ID): New variable.
	(getId): Made non-const.
	* src/BtSuggestPieceMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtPortMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/AbstractBtMessage.h
	(id): Removed.
	(AbstractBtMessage): Removed id.
	(getId): Removed.
	* src/BtHaveMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtAllowedFastMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtCancelMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtNotInterestedMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtChokeMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtRejectMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtBitfieldMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtUnchokeMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtRequestMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.
	* src/BtHaveMessage.h
	(ID_t): Removed.
	(ID): New variable.
	(getId): Made non-const.

	To add --force-truncate command-line option and a check whether
	the file already exists:
	
	* src/DirectDiskAdaptor.h
	(getFilePath): Made virtual public.
	* src/MultiDiskAdaptor.h
	(File.h): New include.
	(DiskWriterEntry::fileEntry): Made private.
	(DiskWriterEntry::fileExists): New function.
	(DiskWriterEntry::getFileEntry): New function.
	(fileExists): New function.
	(getFilePath): New function.
	* src/TorrentRequestInfo.cc
	(FatalException.h): New include.
	(message.h): New include.
	(RecoverableException.h): New include.
	(execute): Added a check whether file is already exists or not.
	* src/DiskAdaptor.h
	(fileExists): New function.
	(getFilePath): New function.
	* src/main.cc
	(showUsage): Added an explanation of --force-truncate 
command-line
	option.
	(main): Added --force-truncate command-line option.
	* src/Exception.h
	(setMsg): buf[256] -> buf[1024]
	* src/CopyDiskWriter.h
	(getFilePath): Made public virtual.
	* src/MultiDiskAdaptor.cc: fileEntry -> getFileEntry()
	(fileExists): New function.
	* src/DownloadEngineFactory.cc
	(newTorrentConsoleEngine): Don't open file here.
	* src/message.h
	(EX_FILE_ALREADY_EXISTS): New definition.
	* src/prefs.h
	(PREF_FOECE_TRUNCATE): New definition.
	* src/HttpResponseCommand.cc
	(handleDefaultEncoding): Added a check whether the file already 
exists.
	* src/SegmentMan.h
	(fileExists): New function.
	(shouldCancelDownloadForSafety): New function.
	* src/FtpNegotiateCommand.cc
	(recvSize): Added a check whether the file already exists.
	* src/AbstractSingleDiskAdaptor.cc
	(File.h): New include.
	(fileExists): New function.
	* src/AbstractSingleDiskAdaptor.h
	(getFilePath): Removed.
	(fileExists): New function.
	* src/SegmentMan.cc
	(fileExists): New function.
	(shouldCancelDownloadForSafety): New function.

	To fix regression bug in torrent downloading:
	
	* src/DefaultBtRequestFactory.cc
	(doChokedAction): New function.
	* src/DefaultBtRequestFactory.h
	(doChokedAction): New function.
	* src/DefaultBtMessageDispatcher.cc
	(doChokedAction): Do not delete request if its target is in 
allowed
	fast set.
	* src/DefaultBtInteractive.cc
	(doPostHandshakeProcessing): Added a call to 
sendPendingMessage().
	(sendKeepAlive): Send keep alive message even if the outgoing 
message
	queue is not empty.
	(decideInterest): Simplified the code.
	(fillPiece): Remove a call to dispatcher->doChokedAction() 
because
	it is already called when BtChokeMessage is received from a 
peer.
	* src/BtRequestFactory.h
	(doChokedAction): New function.

	To clean up code:
	
	* src/PeerInteractionCommand.h
	(executeInternal): Added virtual keyword explicitly.
	(prepareForRetry): Added virtual keyword explicitly.
	(prepareForNextPeer): Added virtual keyword explicitly.
	(onAbort): Added virtual keyword explicitly.

	* src/RequestSlot.cc
	(isTimeout): Use Time::elapsed() instead of 
differenceInMillis().

	* src/BtPieceMessage.cc
	(doReceivedAction): Added a debug log of piece's bitfield.
	* src/Piece.h
	(getBitfieldLength): New function.

	* src/ByteArrayDiskWriter.cc
	(clear): Added buf = 0 to avoid double free corruption.

	* src/FileAllocator.cc
	(allocate): Fixed an assignment of 
fileAllocationMonitor->currentValue.
	Added cp.reset().

	* src/BitfieldMan.h
	(operator=): Rewritten.
	* src/BitfieldMan.cc
	(BitfieldMan): Initialized bitfield, useBitfield.
	
	* src/PeerConnection.cc
	(receiveMessage): Added a call to socket->readable() after 
getting
	message length to avoid possible EOF.

	* src/Util.cc
	(torrentUrlencode): Fixed an encodeing bug. BUG#1629912
2007-01-11 16:32:31 +00:00
Tatsuhiro Tsujikawa e8034f2fd4 Update po files. 2007-01-08 00:19:15 +00:00
Tatsuhiro Tsujikawa 3a412f89b2 2007-01-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add an ability to pre-allocate file space:
	
	* src/DirectDiskAdaptor.h: Rewritten.
	* src/PieceStorage.h: DiskAdaptor -> DiskAdaptorHandle
	* src/MultiDiskAdaptor.h: Rewritten.
	* src/DefaultPieceStorage.cc
	(MultiDiskWriter.h): Removed include.
	(PreAllocationDiskWriter.h): Removed include.
	(FileAllocationMonitor.h): New include.
	(~DefaultPieceStorage): Removed deletion of diskAdaptor.
	(initStorage): Rewritten.
	(getDiskAdaptor): DiskAdaptor -> DiskAdaptorHandle
	* src/FileAllocator.h: New class.
	* src/FileAllocator.cc: New class.
	* src/FileAllocationMonitor.h: New class.
	* src/FileAllocationMonitor.cc: New class.
	* src/ConsoleFileAllocationMonitor.h: New class.
	* src/ConsoleFileAllocationMonitor.cc: New class.
	* src/AbstractSingleDiskAdaptor.h: New class.
	* src/AbstractSingleDiskAdaptor.cc: New class.
	* src/DiskAdaptor.h
	(Directory.h): Removed include.
	(DiskWriter.h): Removed include.
	(FileEntry.h): Removed include.
	(diskWriter): Removed.
	(DiskAdaptor): Removed diskWriter.
	(openFile): Made pure virtual.
	(closeFile): Made pure virtual.
	(openExistingFile): Made pure virtual.
	(initAndOpenFile): Made pure virtual.
	(writeData): Made pure virtual.
	(readData): Made pure virtual.
	(sha1Sum): Made pure virtual.
	(getStoreDir): Returns const reference of storeDir.
	(DiskAdaptorHandle): New type definition.
	* src/main.cc
	(ConsoleFileAllocationMonitor.h): New include.
	(showUsage): Added default value description of -s option.
	Added the description of --file-allocation option.
	(main): Set default value of --file-allocation option to 'none'.
	Added --file-allocation command-line option.
	Setup FileAllocationMonitorFactory.
	* src/FtpInitiateConnectionCommand.cc
	(executeInternal): Removed diskWriter related processing, which 
was
	moved to FtpNegotiationCommand.cc.
	* src/DirectDiskAdaptor.cc
	(getFilePath): Made non-const.
	* src/CopyDiskAdaptor.h
	(DiskAdaptor.h): Removed include.
	(DiskWriter.h): Removed include.
	(AbstractSingleDiskAdaptor.h): New include.
	(getFilePath): Made non-const. Added virtual keyword.
	(CopyDiskAdaptor): Removed diskWriter.
	(getTempFile): Returns const reference.
	(CopyDiskAdaptorHandle): New type definition.
	* src/ByteArrayDiskWriter.cc
	(clear): Simplified.
	(initAndOpenFile): Rewritten.
	(openFile): Call initAndOpenFile()
	* src/MultiDiskAdaptor.cc: Rewritten.
	* src/DownloadEngineFactory.cc
	(FileAllocator.h): New include.
	(FileAllocationMonitor.h): New include.
	(newConsoleEngine): Call 
DefaultDiskWriter::createNewDiskWriter() to
	create DefaultDiskWriter with file allocator.
	* src/DiskWriter.h
	(initAndOpenFile): Added totalLength argument.
	(openFile): Added totalLength argument.
	* src/prefs.h
	(PREF_FILE_ALLOCATION): New definition.
	(V_PREALLOC): New definition.
	(V_NONE): New definition.
	* src/HttpResponseCommand.cc
	(handleDefaultEncoding): Call DefaultDiskWriter::initAndOpenFile 
with
	size.
	* src/FtpNegotiateCommand.cc
	(Util.h): New include.
	(recvSize): Open file here.
	* src/Util.h
	(ullitos): New function.
	* src/CopyDiskWriter.h
	(getFilePath): Made non-const.
	* src/DefaultDiskWriter.h
	(Option.h): New include.
	(totalLength): Removed.
	(DefaultDiskWriter): Removed totalLength.
	(initAndOpenFile): Added totalLength argument.
	(DefaultDiskWriterHandle): New type definition.
	(createNewDiskWriter): New function.
	* src/Util.cc
	(ullitos): New function.
	* src/DefaultDiskWriter.cc
	(message.h): New include.
	(FileAllocator.h): New include.
	(prefs.h): New include.
	(Util.h): New include.
	(DefaultDiskWriter): Removed totalLength.
	(initAndOpenFile): Added file allocation.
	(createNewDiskWriter): New function. Just for temporary 
solution.
	It will be rewritten later.
	* src/DiskAdaptor.cc
	(DiskAdaptor): Removed diskWriter.
	* src/AbstractDiskWriter.cc
	(LogFactory.h): New include.
	(AbstractDiskWriter): Added fileAllocator, logger.
	(openFile): Added totalLength argument.
	* src/AbstractDiskWriter.h
	(FileAllocator.h): New include.
	(Logger.h): New include.
	(fileAllocator): New variable.
	(logger): New variable.
	(openFile): Added totalLength argument. Added virtual keyword
	explicitly.
	(openExistingFile): Added totalLength argument. Added virtual 
keyword
	explicitly.
	(closeFile): Added virtual keyword explicitly.
	(sha1Sum): Added virtual keyword explicitly.
	(writeData): Added virtual keyword explicitly.
	(readData): Added virtual keyword explicitly.
	(setFileAllocator): New function.
	* src/DefaultPieceStorage.h
	(FileAllocator.h): New include.
	(diskAdaptor): DiskAdaptor -> DiskAdaptorHandle
	(getDiskAdaptor): DiskAdaptor -> DiskAdaptorHandle
	* src/FileProgressMonitor.h: New class.

	To compile aria2 on PC-BSD:
	
	* src/DefaultBtContext.cc
	(libgen.h): New include.
	
	To fix memory leak:
	
	* src/Exception.h
	(~Exception): Delete cause. Fixed memory leak.
2007-01-08 00:13:25 +00:00
Tatsuhiro Tsujikawa a413cb50f7 2006-12-24 15:55:59 +00:00
Tatsuhiro Tsujikawa 708b9f4a3d * src/SuggestPieceMessage.h: Removed.
* src/PortMessage.h: Removed.
	* src/SuggestPieceMessage.h: Removed.
	* src/KeepAliveMessage.h: Removed.
	* src/HandshakeMessage.h: Removed.
	* src/PeerInteraction.h: Removed.
	* src/UnchokeMessage.h: Removed.
	* src/PieceMessage.h: Removed.
	* src/RequestMessage.h: Removed.
	* src/InterestedMessage.h: Removed.
	* src/HaveMessage.h: Removed.
	* src/CancelMessage.h: Removed.
	* src/RejectMessage.h: Removed.
	* src/AllowedFastMessage.h: Removed.
	* src/HaveNoneMessage.h: Removed.
	* src/SimplePeerMessage.h: Removed.
	* src/HaveAllMessage.h: Removed.
	* src/BitfieldMessage.h: Removed.
	* src/PeerMessageFactory.h: Removed.
	* src/NotInterestedMessage.h: Removed.
	* src/ChokeMessage.h: Removed.
	* src/PeerMessage.h: Removed.
2006-12-24 07:10:43 +00:00
Tatsuhiro Tsujikawa 9c3e8fbd9c 2006-12-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
2006-12-24 06:25:21 +00:00
Tatsuhiro Tsujikawa 458cc27462 2006-12-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
2006-12-01 09:31:46 +00:00