Commit Graph

14 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa
81f46fbf92 Use CXX11_OVERRIDE 2013-07-06 18:15:09 +09:00
Tatsuhiro Tsujikawa
098f1571be Wrap BtMessage objects by std::unique_ptr instead of std::shared_ptr 2013-06-30 22:55:43 +09:00
Tatsuhiro Tsujikawa
07d270c87e Require -std=c++11 and use std::shared_ptr instead of SharedHandle 2013-06-22 01:10:38 +09:00
Tatsuhiro Tsujikawa
2b458da480 2010-10-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made #include guard consistent for c++ header files.
2010-10-31 07:23:53 +00:00
Tatsuhiro Tsujikawa
c342bde962 2010-02-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use vector instead of deque for containers which is used for
	mostly read-only purpose.
2010-02-28 12:30:11 +00:00
Tatsuhiro Tsujikawa
67767e2f61 2008-09-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that a block in a piece is requested when same 
block is
	already requested to the same peer in end game mode.
	* src/BtRequestFactory.h
	* src/DefaultBtInteractive.cc
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* src/DefaultPieceStorage.cc
	* src/DefaultPieceStorage.h
	* src/PieceStorage.h
	* src/UnknownLengthPieceStorage.cc
	* src/UnknownLengthPieceStorage.h
	* test/DefaultBtRequestFactoryTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/MockBtRequestFactory.h
	* test/MockPieceStorage.h
2008-09-19 14:11:41 +00:00
Tatsuhiro Tsujikawa
dfe2f99345 2008-06-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Filled up pieces based on the number of missing blocks, rather 
than
	simplay the number of piece * block length.
	* src/BtRequestFactory.h
	* src/DefaultBtInteractive.cc
	* src/DefaultBtInteractive.h
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* src/Piece.cc
	* src/Piece.h
	* test/BitfieldManTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/MockBtRequestFactory.h
2008-06-17 11:43:29 +00:00
Tatsuhiro Tsujikawa
ddd1206b42 2008-05-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed method signature:
	BtRequestFactory::createRequestMessages,
	BtRequestFactory::createRequestMessagesOnEndGame
	* src/BtRequestFactory.h
	* src/DefaultBtInteractive.cc
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* test/DefaultBtRequestFactoryTest.cc
	* test/MockBtRequestFactory.h
2008-05-12 10:54:36 +00:00
Tatsuhiro Tsujikawa
032c7c2808 2008-03-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
type cleanup for allmost all remaining files.
2008-03-09 12:24:01 +00:00
Tatsuhiro Tsujikawa
518a200d57 2008-03-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Type clarification: size_t for length or size, uint64_t for file
	length, off_t for file offset.

	* src/PiecedSegment.cc
	* src/GrowSegment.h
	* src/DefaultBtRequestFactory.h
	* src/DefaultBtProgressInfoFile.cc
	* src/UnknownLengthPieceStorage.h
	* src/DefaultPieceStorage.cc
	* src/UnknownLengthPieceStorage.cc
	* src/DefaultBtInteractive.cc
	* src/GrowSegment.cc
	* src/BitfieldMan.h
	* src/DownloadCommand.cc
	* src/BtRequestFactory.h
	* src/PiecedSegment.h
	* src/DefaultPieceStorage.h
	* src/Piece.cc
	* src/DefaultBtRequestFactory.cc
	* src/PieceStorage.h
	* src/Segment.h
	* src/Piece.h
	* src/BitfieldMan.cc
	* src/Util.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/MockPieceStorage.h
	* test/BtRequestMessageTest.cc
	* test/DefaultBtMessageDispatcherTest.cc
	* test/BitfieldManTest.cc
	* test/GrowSegmentTest.cc
	* test/PieceTest.cc
	* test/SegmentTest.cc
	* test/SegmentManTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/MockBtRequestFactory.h
2008-03-08 08:04:28 +00:00
Tatsuhiro Tsujikawa
1b7c198289 2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed "using namespace std;" from all sources. Appended std:: 
prefix to c++
	standard classes.
	Included string.h where mem* function are used.
2008-02-08 15:53:45 +00:00
Tatsuhiro Tsujikawa
3cc1ed5e09 2007-08-10 Ross Smith II <aria2spam at smithii dot com>
gcc 3.4.4 support:
	* src/DefaultBtContext.cc: int32_t -> int
	* src/main.cc: int -> int32_t, int32_t -> int
	* src/messageDigest.h: uint32_t -> unsigned int
	* src/NameResolver.h: int32_t -> int
	* src/PeerConnection.cc: int -> int32_t
	* src/SpeedCalc.cc: int32_t -> int
	* src/TrackerUpdateCommand.h: int -> int32_t
	* src/Util.cc: int32_t -> int
	* src/Util.h: int32_t -> int
	* src/Xml2MetalinkProcessor.cc: int -> uint32_t, int64_t -> 
uint64_t
	* test/AnnounceListTest.cc: int -> int32_t
	* test/ChunkedEncodingTest.cc: int -> int32_t
	* test/DataTest.cc: int -> int32_t
	* test/DefaultBtRequestFactoryTest.cc: int -> int32_t
	* test/DefaultPeerListProcessorTest.cc: int -> int32_t
	* test/DefaultPieceStorageTest.cc: int -> int32_t
	* test/FeatureConfigTest.cc: int -> int32_t
	* test/MetalinkEntryTest.cc: int -> int32_t
	* test/MockBtRequestFactory.h: int -> int32_t
	* test/MockPieceStorage.h: int -> int32_t
	* test/OptionTest.cc: int -> int32_t
	* test/RequestTest.cc: int -> int32_t
	* test/SegmentManTest.cc: int -> int32_t
	* test/Xml2MetalinkProcessorTest.cc: int -> int32_t
2007-08-15 15:11:01 +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
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