Commit Graph

12 Commits (e9f980afc73965d746c6f7fb4ed019e3567c67b4)

Author SHA1 Message Date
Tatsuhiro Tsujikawa c064a2cd9e 2008-02-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Extract the Peer class's member variables, which are only needed 
after
	PeerInteractionCommand, into PeerSessionResource class.
	This class is instantiated in PeerInteractionCommand class's 
ctor and
	released in its dtor.
	This will make Peer class lightweight and uses less memory for 
peers
	which are not connected and wait in the queue.
	* src/PeerChokeCommand.cc
	* src/PeerSessionResource.{h, cc}
	* src/PeerInteractionCommand.cc
	* src/PeerAbstractCommand.cc: Note: 0 is given to onAbort() 
function.
	* src/DefaultBtInteractive.cc
	* src/BtPieceMessage.cc
	* src/BtInterestedMessage.cc
	* src/BtUnchokeMessage.cc
	* src/DefaultPeerStorage.{h, cc}
	* src/PeerInitiateConnectionCommand.cc
	* src/ActivePeerConnectionCommand.cc
	* src/BtNotInterestedMessage.cc
	* src/DefaultBtMessageDispatcher.cc
	* src/BtChokeMessage.cc
	* src/BtRequestMessage.cc
	* src/Peer.{h, cc}
	* src/BtRegistry.h
	* src/TrackerWatcherCommand.cc
	* src/PeerReceiveHandshakeCommand.cc
	* test/BtExtendedMessageTest.cc
	* test/BtAllowedFastMessageTest.cc
	* test/BtCancelMessageTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/BtBitfieldMessageTest.cc
	* test/BtHaveMessageTest.cc
	* test/BtNotInterestedMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/PeerSessionResourceTest.cc
	* test/DefaultBtMessageDispatcherTest.cc
	* test/PeerTest.cc
	* test/BtInterestedMessageTest.cc
	* test/BtRejectMessageTest.cc
	* test/BtChokeMessageTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/BtHaveNoneMessageTest.cc
	* test/BtHaveAllMessageTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/BtUnchokeMessageTest.cc
	* test/DefaultBtMessageFactoryTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/UTPexExtensionMessageTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/BtPieceMessageTest.cc
	
	Removed typedef PeerStats.
	* src/PeerStat.h
	* src/SegmentMan.cc
2008-02-09 17:14:40 +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 e39f7a7e9c 2007-12-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Allocate bitfield in Peer when it is really used. More 
specifically,
	bitfield in Peer is allocated after the connection is 
established and
	deallocated when the connection is dropped.
	Since 2 parameters(piece length and total length) was removed 
from the
	constructor of Peer class, many test classes were modified 
accordingly.
	See svn log for more detailed information.
	* src/PeerInteractionCommand.cc
	* src/CompactPeerListProcessor.cc
	* src/Peer.cc
	* src/DefaultPeerListProcessor.cc
	* src/PeerListenCommand.cc
	* src/PeerReceiveHandshakeCommand.cc

	Fixed memory leak
	* src/Piece.cc
2007-12-26 14:26:55 +00:00
Tatsuhiro Tsujikawa 30739b0763 2007-12-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug: aria2 doesn't utilize fast set index offered by peer.
	* src/Peer.{h, cc}
	* src/DefaultPieceStorage.cc
	* test/DefaultPieceStorageTest.cc
2007-12-05 17:57:08 +00:00
Tatsuhiro Tsujikawa ab8c0aafeb 2007-11-17 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented. Now -c option works fine.
	* src/DefaultPieceStorage.cc (markPiecesDone)
	* test/DefaultPieceStorageTest.cc

	Removed.
	* src/SegmentMan.{h, cc}
	(markAllPiecesDone)
	(markPieceDone)

	Synchronized po files with 
	https://translations.launchpad.net/aria2/trunk/+pots/aria2c
	* src/fr.po
	* src/ru.po
	* src/de.po
	* src/ja.po
2007-11-17 13:49:36 +00:00
Tatsuhiro Tsujikawa a31dbb5804 2007-11-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added ifdef and some modifications to compile without 
BitTorrent,
	Metalink, MessageDigest
	support.
	* src/PieceHashCheckIntegrityEntry.cc
	* src/MetalinkEntry.h
	* src/version_usage.cc
	* src/main.cc
	* src/DownloadEngine.{h, cc}
	* src/Metalink2RequestGroup.cc
	* src/Peer.cc
	* src/RequestGroup.cc
	* src/MetalinkHelper.cc
	* test/DefaultPieceStorageTest.cc
	* test/MetalinkPostDownloadHandlerTest.cc
	* test/Metalink2RequestGroupTest.cc

	Hide TOTAL SPD when all downloads complete.
	* src/ConsoleStatCalc.cc

	Log target system information.
	* src/main.cc
2007-11-14 10:10:38 +00:00
Tatsuhiro Tsujikawa b4f7588ba2 2007-11-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Reflect the download length of in-flight pieces.
	It makes the download length readout more precise.
	* src/DefaultPieceStorage.{h, cc}
	* test/DefaultPieceStorageTest.cc
	* src/a2functional.h
	* test/a2functionalTest.cc
	
	Lower CPU load when --max-download-limit is used.
	There is up and down in speed indicator when enabling
	http-pipelining but a download goes well. I think the problem is 
that
	because http-pipelining is enabled, DownloadCommand is created 
for
	each segment and in its constructor, PeerStat::downloadStart() 
is
	called. In PeerStat::downloadStart(), speed calculation object 
is
	reseted, which makes download speed zero.
	* src/DownloadCommand.cc

	Rewritten using accumulate.
	* src/RequestGroupMan.cc (calculateStat)
	
	Code clearnup.
	* src/FtpNegotiationCommand.cc
	* src/HttpResponseCommand.cc
2007-11-07 12:36:33 +00:00
Tatsuhiro Tsujikawa 3ab9fe706d 2007-10-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Piece.{h, cc}: Added SubPiece infrastructure to track down
	the data smaller than block length.
	A block length can be specified by constructor's argument.
	* src/DefaultPieceStorage.{h, cc} (getMissingPiece):
	Get a missing piece in the range of given FileEntry. This 
function is
	not used in the program yet.
	* src/Util.h: Added some macros.
2007-10-23 16:29:37 +00:00
Tatsuhiro Tsujikawa 048a2cf597 2007-10-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented BitTorrent/http/ftp integrated download.
	I've rewritten lots of files and now some headers have forward
	class declarations to reduce compile time.
	The implementation is extremely alpha stage, I recommend to use this
	for testing purpose only.
2007-10-11 16:58:24 +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 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 ec642ad294 2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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".
2006-11-05 15:04:17 +00:00