Commit Graph

144 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa
8b8e769aaa Updated doc 2006-08-07 16:47:52 +00:00
Tatsuhiro Tsujikawa
6620c8d878 2006-08-07 16:43:58 +00:00
Tatsuhiro Tsujikawa
2c0b8d13ad 2006-08-07 16:29:42 +00:00
Tatsuhiro Tsujikawa
19d593413c 2006-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* po/ru.po: Azamat sent me Russian translation.
	
	* src/FtpNegotiateCommand.cc
	(recvGreeting): Call disableWriteCheckSocket just after
	socket->setBlockingMode(). This avoids unnecessary CPU-hog loop.

	Rename Time.h to TimeA2.h to avoid compilation ploblem on
	case-insesitive filesystem(BUG#1531057).

	* src/Time.h: Renamed as TimeA2.h.
	* src/Time.cc: Renamed as TimeA2.cc.
	* src/TimeA2.h: New class.
	* src/TimeA2.cc: New class.
	* src/PeerChokeCommand.h: Replaced Time.h with TimeA2.h.
	* src/TrackerWatcherCommand.h: Replaced Time.h with TimeA2.h.
	* src/PeerAbstractCommand.h: Replaced Time.h with TimeA2.h.
	* src/AbstractCommand.h: Replaced Time.h with TimeA2.h.
	* src/PeerInteractionCommand.h: Replaced Time.h with TimeA2.h.
	* src/ConsoleDownloadEngine.h: Replaced Time.h with TimeA2.h.
	* src/TorrentAutoSaveCommand.h: Replaced Time.h with TimeA2.h.
	* src/DownloadCommand.h: Replaced Time.h with TimeA2.h.
	* src/TorrentMan.h: Replaced Time.h with TimeA2.h.
	* src/TorrentDownloadEngine.h: Replaced Time.h with TimeA2.h.
	* src/RequestSlot.h: Replaced Time.h with TimeA2.h.
	* src/SleepCommand.h: Replaced Time.h with TimeA2.h.
	* src/DownloadEngine.cc: Replaced Time.h with TimeA2.h.
2006-08-07 16:28:41 +00:00
Tatsuhiro Tsujikawa
a1d8be3b7c Replaced Time.h with TimeA2.h 2006-08-07 16:09:26 +00:00
Tatsuhiro Tsujikawa
58dbaafc85 2006-08-08 Tatsuhiro Tsujikawa <tujikawa@rednoah.com>
* src/FtpNegotiateCommand.cc
	(recvGreeting): Call disableWriteCheckSocket just after
	socket->setBlockingMode(). This avoids unnecessary CPU-hog loop.

2006-08-07  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	* src/PeerChokeCommand.h
	(PeerChokeCommand): Rearranged the arguments.
	* src/PeerChokeCommand.cc
	(PeerChokeCommand): Rearranged the arguments.

	* src/MetalinkEntry.h
	(Checksum.h): Included.
	(md5): Removed.
	(sha1): Removed.
	(checksum): New variable.
	(operator=): Updated.
	(check): Removed.

	* src/prefs.h
	(PREF_LOWEST_SPEED_LIMIT): New definition.
	(PREF_FOLLOW_TORRENT): New definition.
	(PREF_SELECT_FILE): New definition.
	(PREF_FOLLOW_METALINK): New definition.

	* src/MetalinkResource.h
	(TYPE_HTTPS): Added to enum TYPE.

	* src/TorrentMan.cc
	(~TorrentMan): Rewritten.

	* src/MultiDiskWriter.cc
	(MultiDiskAdaptor): Updated according to the changes in
	MessageDigestContext.
	(~MultiDiskAdaptor): Updated according to the changes in
	MessageDigestContext.
	(hashUpdate): Updated according to the changes in 
MessageDigestContext.
	(sha1Sum): Updated according to the changes in 
MessageDigestContext.

	* src/Util.h
	(fileChecksum): Updated according to the changes in
	MessageDigestContext.
	* src/Util.cc
	(sha1Sum): Updated according to the changes in 
MessageDigestContext.
	(fileChecksum): Updated according to the changes in
	MessageDigestContext.

	* src/messageDigest.h: Rewritten.

	* src/MetalinkEntry.cc
	(check): Removed.
	(Supported): Updated.
	(dropUnsupportedResource): Fixed a memory leak.

	* src/ShaVisitor.cc
	(ShaVisitor): Updated according to the changes in 
MessageDigestContext.
	(~ShaVisitor): Updated according to the changes in
	MessageDigestContext.
	(visit): Updated according to the changes in 
MessageDigestContext.

	* src/main.cc
	(main): Rewritten the portion of download loop. 
--lowest-speed-limit
	command-line option added.

	* src/DownloadEngine.h
	(SocketEntry): New class.
	(SocketEntries): New definition.
	(PairFind): Removed.
	(SockCmdMap): Removed.
	* src/DownloadEngine.cc
	(DownloadEngine): Rewritten.
	(~DownloadEngine): Rewritten.
	(run): Renamed activeCommandUuids as activeUuids.
	(SetDescriptor): Rewritten.
	(AccumulateActiveCommandUuid): Removed.
	(AccumulateActiveUuid): New function object.
	(waitData): Rewritten.
	(updateFdSet): Rewritten.
	(addSocket): Rewritten.
	(deleteSocket): Rewritten.
	(addSocketForReadCheck): Rewritten.
	(deleteSocketForReadCheck): Rewritten.
	(addSocketForWriteCheck): Rewritten.
	(deleteSocketForWriteCheck): Rewritten.
	
	* src/Xml2MetalinkProcessor.cc
	(getEntry): Rewritten the portion of MetalinkEntry creation.

	* src/DownloadCommand.cc
	(executeInternal): Added the check routine for lowest speed 
limit.

	* src/AbstractDiskWriter.cc
	(AbstractDiskWriter): Updated according to the changes in
	MessageDigestContext.
	(~AbstractDiskWriter): Updated according to the changes in
	MessageDigestContext.
	(sha1Sum): Updated according to the changes in 
MessageDigestContext.

	* src/RequestInfo.h: New class.

	* src/UrlRequestInfo.h: New class.
	* src/UrlRequestInfo.cc: New class.

	* src/TorrentRequestInfo.h: New class.
	* src/TorrentRequestInfo.cc: New class.

	* src/MetalinkRequestInfo.h: New class.
	* src/MetalinkRequestInfo.cc: New class.

	* src/Checksum.h: New class.

	* src/DownloadEngineFactory.h: New class.
	* src/DownloadEngineFactory.cc: New class.
2006-08-07 16:05:00 +00:00
Tatsuhiro Tsujikawa
9251b47f6c 2006-08-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Option.h
	(getAsBool): New function.
	* src/Option.cc
	(prefs.h): Included.
	(defined): 0-length value is now recognized as undefined.
	(getAsInt): Rewritten.
	(getAsLLInt): Rewritten.
	(getAsBool): New function.
	
	* src/FeatureConfig.h: Rewritten.
	* src/FeatureConfig.cc: Rewritten.

	* src/prefs.h
	(PREF_STDOUT_LOG): New definition.
	(PREF_LOG): New definition.
	(PREF_DIR): New definition.
	(PREF_OUT): New definition.
	(PREF_SPLIT): New definition.
	(PREF_DAEMON): New definition.
	(PREF_REFERER): New definition.
	(PREF_TORRENT_FILE): New definition.
	(PREF_LISTEN_PORT): New definition.
	(PREF_METALINK_FILE): New definition.
	(PREF_METALINK_VERSION): New definition.
	(PREF_METALINK_LANGUAGE): New definition.
	(PREF_METALINK_OS): New definition.
	(PREF_METALINK_SERVERS): New definition.

	* src/main.cc
	(main): Following command-line parameters are now put into 
Option
	class: stdoutLog, logfile, dir, ufilename, split, daemonMode,
	referer, torrentFile, metalinkFile, listenPort, metalinkVersion,
	metalinkLanguage, metalinkOs, metalinkServers
	To fix the bug that aria2 can not handle http response header 
properly.
	
	* src/HttpHeader.cc
	(put): Made name lowercased.
	(defined): Made name lowercased.
	(getFirst): Made name lowercased.
	(get): Made name lowercased.
	(getFirstAsInt): Rewritten.
	(getFirstAsLLInt): Rewritten.
2006-08-03 12:36:02 +00:00
Tatsuhiro Tsujikawa
928465b7bc 2006-07-30 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/TorrentMan.h:
	(advertisePiece): Updated doc.
	(getAdvertisedPieceIndexes): Updated doc.
	(removeAdvertisedPiece); New function.
	
	* src/TorrentMan.cc
	(FindElapsedHave): New function object.
	(removeAdvertisedPiece): New function.

	* src/HaveEraseCommand.h: New class.
	* src/HaveEraseCommand.cc: New class.

	* src/FeatureConfig.h: New class.
	* src/FeatureConfig.cc: New class.
	
	* src/Request.h
	(defaultPorts): Removed.
	* src/Request.cc
	(FeatureConfig.h): Included.
	(Request): Removed the statements related to defaultPorts.
	(parseUrl): Removed metalinkEnabled. Use FeatureConfig instead.
	A default port number is now retrieved from FeatureConfig.
	
	* src/main.cc
	(HaveEraseCommand.h): Included.
	(showVersion): Added the output of feature list.
	(main): Added HaveEraseCommand to command queue in BitTorrent
	downloading.
	
	* src/PeerInteractionCommand.h
	(chokeCheckPoint): Commented out.
	(periodicExecPoint): New variable.
	* src/PeerInteractionCommand.cc
	(executeInternal): Following methods are now called in at least 
every
	0.5 seconds to reduce CPU usage:
	detectMessageFlooding(), peerInteraction->checkRequestSlot(),
	checkHave(), sendKeepAlive().
	(checkLongTimePeerChoking): Commented out.

	* src/BitfieldMan.h
	(getNthBitIndex): Changed the method signature.
	(getMissingIndexRandomly): Changed the method signature.
	* src/BitfieldMan.cc
	(getNthBitIndex): Rewritten
	(getMissingIndexRandomly): Rewritten.
	(hasMissingPiece): Rewritten.
	(getMissingIndex): Refactored.
	(getMissingUnusedIndex); Refactored.
	(getMissingIndex): Refactored.
2006-07-30 12:58:27 +00:00
Tatsuhiro Tsujikawa
ba4e5b776b 2006-07-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/PeerMessage.h
	(Piece.h): Included.
	(SharedHandle.h): Included.
	(invalidate): New variable.
	(uploading): New variable.
	(isInvalidate): New function.
	(isUploading): New function.
	(onPush): New function.
	(onChoked): New function.
	(onCanceled): New function.
	(onAbortPiece): New function.
	(PeerMessageHandle): New type definition.
	
	* src/PeerMessage.cc
	(PeerMessage): Added the initialization for invalidate and 
uploading.
	
	* src/CancelMessage.h
	(CancelMessage): Rewritten.

	* src/RejectMessage.h
	(RejectMessage): Rewritten.

	* src/Metalinker.h
	(operator=): Defined.
	
	* src/MetaEntry.h
	(operator=): Defined.

	* src/MetalinkResource.h
	(operator=): Defined.
	
	* src/AllowedFastMessage.h
	(AllowedFastMessage): Rewritten.

	* src/HandshakeMessage.h
	(HandshakeMessage): New function(overload).
	
	* src/HandshakeMessage.cc
	(HandshakeMessage): Rewritten.
	(init): New function.

	* src/HaveMessage.h
	(HaveMessage): Rewritten.
	
	* src/Time.h
	(operator=): Defined the function body here.
	* src/Time.cc
	(operator=): Removed.
	
	* src/SocketCore.h
	(operator==): Defined here.
	(operator!=): Defined here.
	(operator<): Defined here.
	* src/SocketCore.cc
	(operator==): Removed.
	(operator<): Removed.

	* src/BitfieldMan.h
	(operator=): Defined the function body here.
	* src/BitfieldMan.cc
	(operator=): Removed.

	* src/TorrentMan.h
	(deleteErrorPeer): Removed.
	(deleteUnusedPeer); New function.
	* src/TorrentMan.cc
	(addPeer): Call deleteUnusedPeer.
	(deleteErrorPeer): Removed.
	(deleteUnusedPeer): New function.

	* src/PeerAbstractCommand.h
	(setNoCheck): New function.
	(noCheck): New variable.
	* src/PeerAbstractCommand.cc
	(PeerAbstractCommand): Added the initialization of noCheck.
	(execute): Added a check for noCheck.
	(setNoCheck): New function.

	* src/Util.h
	(stdio.h): Included.
	* src/Util.cc
	(unistd.h): Included.

	* src/DefaultDiskWriter.cc
	(unistd.h): Included.

	* src/Peer.h
	(operator==): Defined the function body here.
	(operator!=): Defined the function body here.
	* src/Peer.cc
	(operator==): Removed.
	(operator!=): Removed.

	* src/Piece.h
	(Piece): Defined the function body here(copy constructor).
	(operator=): Defined the function body here.
	(operator==): Defined the function body here.
	* src/Piece.cc
	(Piece): Removed(copy constructor).
	(operator=): Removed.
	(operator==): Removed.
	
	* src/PeerMessageUtil.h
	(ChokeMessage.h): Removed.
	(UnchokeMessage.h): Removed.
	(InterestedMessage.h): Removed.
	(NotInterestedMessage.h): Removed.
	(HaveMessage.h): Removed.
	(BitfieldMessage.h): Removed.
	(RequestMessage.h): Removed.
	(CancelMessage.h): Removed.
	(PieceMessage.h): Removed.
	(HandshakeMessage.h): Removed.
	(KeepAliveMessage.h): Removed.
	(PortMessage.h): Removed.
	(HaveAllMessage.h): Removed.
	(HaveNoneMessage.h): Removed.
	(PeerConnection.h): Removed.
	(HandshakeMessage.h): Included.

	* src/BitfieldMessage.h
	(init): New function.
	(BitfieldMessage): Rewritten.
	(BitfieldMessage): New function(overload).

	* src/RequestSlot.h
	(operator=): Defined the function body here.
	(operator==): Defined the function body here.
	* src/RequestSlot.cc
	(operator=): Removed.
	(operator==): Removed.
	
	To remove the dependency on the PeerMessage subclass from
	PeerInteraction:

	* src/PeerMessageFactory.h: New class.
	* src/PeerMessageFactory.cc: New class.
	* src/SimplePeerMessage.cc
	(send): If invalidate is true then do nothing.
	* src/PeerInteractionCommand.cc
	(HandshakeMessage.h): Included.
	(KeepAliveMessage.h): Included.
	(ChokeMessage.h): Included.
	(UnchokeMessage.h): Included.
	(HaveMessage.h): Included.
	(executeInternal): Call setNoCheck().
	Removed setWriteCheckSocket(socket).
	* src/PeerInteraction.h
	(ChokeMessage.h): Removed.
	(UnchokeMessage.h): Removed.
	(InterestedMessage.h): Removed.
	(NotInterestedMessage.h): Removed.
	(HaveMessage.h): Removed.
	(BitfieldMessage.h): Removed.
	(RequestMessage.h): Removed.
	(CancelMessage.h): Removed.
	(PieceMessage.h): Removed.
	(HandshakeMessage.h): Removed.
	(KeepAliveMessage.h): Removed.
	(PortMessage.h): Removed.
	(HaveAllMessage.h): Removed.
	(HaveNoneMessage.h): Removed.
	(RejectMessage.h): Removed.
	(AllowedFastMessage.h): Removed.
	(SuggestPieceMessage.h): Removed.
	(PeerMessageFactory.h): Included.
	(PeerMessageHandle): Removed typedef of PeerMessageHandle.
	(HandshakeMessageHandle): Removed typedef of 
HandshakeMessageHandle.
	(PeerMessageFactory): New variable.
	(createPeerMessage): Removed.
	(createHandshakeMessage): Removed.
	(setPeerMessageCommonProperty): Removed.
	(addRequestSlot): New function.
	(receiveHandshake): Changed the return value type to 
PeerMessageHandle.
	(getPeerMessageFactory): New function.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createHaveMessage): Removed.
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createBitfieldMessage): Removed.
	(createKeepAliveMessage): Removed.
	(createHaveAllMessage): Removed.
	(createHaveNoneMessage): Removed.
	(createRejectMessage): Removed.
	(createAllowedFastMessage): Removed.	
	* src/PeerInteraction.cc
	(PeerInteraction): Allocate PeerMessageFactory here.
	(~PeerInteraction): Deallocate PeerMessageFactory here.
	(sendMessages): Use msg->isUploading() instead of msg->getId() 
==
	PieceMessage::ID.
	(addMessage): Simplified by using PeerMessage::onPush().
	(addRequestSlot): New function.
	(rejectAllPieceMessageInQueue): Simplified by using
	PeerMessage::onChoked().
	(rejectPieceMessageInQueue): Simplified by using
	PeerMessage::onCanceled().
	(abortPiece): Simplified by using PeerMessage::abortPiece().
	(receiveHandshake): Changed the return value type to 
PeerMessageHandle.
	(createHandshakeMessage): Removed.
	(createPeerMessage): Removed.
	(sendHandshake): Call 
PeerMessageFactory::createHandshakeMessage().
	(setPeerMessageCommonProperty): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createHaveMessage): Removed.
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createBitfieldMessage): Removed.
	(createKeepAliveMessage): Removed.
	(createHaveAllMessage): Removed.
	(createHaveNoneMessage): Removed.
	(createRejectMessage): Removed.
	(createAllowedFastMessage): Removed.
	* src/PieceMessage.h
	(createRejectMessage): New function.
	(PieceMessage): Rewritten.
	(onChoked): New function.
	(onCanceled): New function.
	* src/PieceMessage.cc
	(send): If invalidate is true then do nothing, just return.
	(createRejectMessage): New function.
	(onChoked): New function.
	(onCanceled): New function.
	* src/RequestMessage.h
	(RequestMessage): Rewritten.
	(onPush): New function.
	(onAbortPiece): New function.
	* src/RequestMessage.cc
	(onPush): New function.
	(onAbortPiece): New function.
	
	Update fd_set when a socket is added or deleted in order to 
improve
	performance:

	* src/DownloadEngine.h
	(rfdset): New variable.
	(wfdset): New variable.
	(updateFdSet): New function.
	* src/DownloadEngine.cc
	(SetDescriptor::operator()): Use SockCmdMap::value_type.
	(AccumulateActiveCommandUuid::operator()): Use 
SockCmdMap::value_type.
	(waitData): Copy rfdset and wfdset.
	(updateFdSet): New function.
	(addSocket): Call updateFdSet.
	(deleteSocket): Call updateFdSet.
2006-07-28 14:06:47 +00:00
Tatsuhiro Tsujikawa
793d9b75ce Added ShardHandle.h 2006-07-22 13:24:40 +00:00
Tatsuhiro Tsujikawa
941e0108d3 2006-07-20 15:57:25 +00:00
Tatsuhiro Tsujikawa
7db2b0596d 2006-07-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the support for Metalink3.0 backward compatible links:
	
	* src/Request.h
	(SAFE_CHARS): Added '#'.
	(METALINK_MARK): New definition.
	* src/Request.cc
	(parseUrl): Added the support for Metalink3.0 backward 
compatible
	links.

	etc

	* src/PeerInteraction.cc
	(MsgPushBack): Removed.
	(sendMessages): Use STL copy and back_inserter.
	(rejectAllPieceMessageInQueue): Use STL copy and back_inserter.
	(rejectPieceMessageInQueue): Use STL copy and back_inserter.
	* src/TorrentMan.h
	(MAX_PEER_LIST_SIZE): Changed to 100 from 250.
2006-07-20 15:48:12 +00:00
Tatsuhiro Tsujikawa
524d664850 2006-07-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/SharedHandle.h: New class.

	To wrap Socket, Command, PeerMessage and Peer with SharedHandle:

	* src/HttpResponseCommand.h
	(HttpResponseCommand): Wrapped Socket.
	* src/SocketCore.h
	(operator==): New function.
	(operator!=): New function.
	(operator<): New function.
	(getSockfd): New function.
	(isOpen): New function.
	(writeData): New function.
	* src/SocketCore.cc
	(operator==): New function.
	(operator!=): New function.
	(operator<): New function.
	* src/AbstractCommand.h
	(socket): Changed its type to SocketHandle.
	(setReadCheckSocket): Replaced Socket with SocketHandle.
	(setWriteCheckSocket): Replaced Socket with SocketHandle.
	(disableReadCheckSocket): New function.
	(disableWriteCheckSocket): New function.
	(readCheckTarget): Changed its type to SocketHandle.
	(writeCheckTarget): Changed its type to SocketHandle.
	(AbstractCommand): Replaced Socket with SocketHandle.
	* src/AbstractCommand.cc
	(AbstractCommand): Replaced Socket with SocketHandle.
	(~AbstractCommand): Removed the deallocation for Socket object.
	(disableReadCheckSocket): New function.
	(setReadCheckSocket): Replaced Socket with SocketHandle.
	(disableWriteCheckSocket): New function.
	(setWriteCheckSocket): Replaced Socket with SocketHandle.
	* src/HttpDownloadCommand.cc
	(DownloadCommand): Replaced Socket with SocketHandle.
	* src/PeerAbstractCommand.h
	(socket): Changed its type to SocketHandle.
	(peer): Changed its type to PeerHandle.
	(setReadCheckSocket): Replaced Socket with SocketHandle.
	(setWriteCheckSocket): Replaced Socket with SocketHandle.
	(disableReadCheckSocket): New function.
	(disableWriteCheckSocket): New function.
	(readCheckTarget): Changed its type to SocketHandle.
	(writeCheckTarget): Changed its type to SocketHandle.
	(PeerAbstractCommand): Replaced Socket with SocketHandle.
	Replaced Peer with PeerHandle.
	* src/HttpRequestCommand.cc
	(HttpRequestCommand): Replaced Socket with SocketHandle.
	Use disableReadCheckSocket.
	* src/PeerInitiateConnectionCommand.h
	(PeerInitiateConnectionCommand): Replaced Peer with PeerHandle.
	* src/PeerChokeCommand.cc
	(UploadFaster::operator()): Replaced Peer with PeerHandle.
	(DownloadFaster::operator()): Replaced Peer with PeerHandle.
	(execute): Use PeerHandle.
	* src/PeerConnection.h
	(HandshakeMessage.h): Removed include of HandshakeMessage.h.
	(socket): Changed its type to SocketHandle.
	(PeerConnection): Replaced Socket with SocketHandle.	
	* src/PeerConnection.cc
	(PeerConnection): Replaced Socket with SocketHandle.
	* src/PeerInteractionCommand.h
	(PeerInteractionCommand): Replaced socket with SocketHandle.
	Replaced Peer with PeerHandle.	
	* src/PeerInteractionCommand.cc
	(PeerInteractionCommand): Replaced Socket with SocketHandle.
	Replaced Peer with PeerHandle.
	(executeInternal): Use disableWriteCheckSocket.
	Use HandshakeMessageHandle.
	(receiveMessages): Use PeerMessageHandle.
	(prepareForNextPeer): Use PeerHandle.
	* src/HttpProxyRequestCommand.h
	(HttpProxyRequestCommand): Replaced Socket with SocketHandle.
	* src/HttpResponseCommand.cc
	(HttpResponseCommand): Replaced Socket with SocketHandle.
	* src/TorrentMan.cc
	(nullPeer): Added external reference.
	(~TorrentMan): Removed the deallocation of the elements of 
peers.
	(addPeer): Rewritten.
	(isPeerAvailable): Use nullPeer.
	(deleteOldpeers): Replaced with deleteErrorPeer.
	(deleteErrorPeer): New function.
	(getPeer): Use PeerHandle and nullPeer.
	(hasMissingPiece): Replaced Peer with PeerHandle.
	(getMissingPieceIndex): Replaced Peer with PeerHandle.
	(getMissingFastPieceIndex): Replaced Peer with PeerHandle.
	(getMissingFastPiece): Replaced Peer with PeerHandle.
	(getMissingPiece): Replaced Peer with PeerHandle.
	* src/FtpNegotiateCommand.cc
	(FtpNegotiationCommand): Replaced Peer with PeerHandle.
	(~FtpNegotiationCommand): Removed the deallocation of Sockets.
	(recvGreeting): Use disableWriteCheckSocket.
	(recvPasv): Removed the allocation of Socket.
	Use disableReadCheckSocket.
	(sendRestPasv): Use disableWriteCheckSocket.
	(recvRetr): Changed assertion.
	* src/PeerInteraction.h
	(SharedHandle.h): Included SharedHandle.h.
	(PeerMessageHandle): New type definition.
	(HandshakeMessageHandle): New type definition.
	(MessageQueue): Changed. Now its element is of type 
PeerMessageHandle.
	(peer): Changed its type to PeerHandle.
	(createHandshakeMessage): Replaced HandshakeMessage with
	HandshakeMessageHandle.
	(createPeerMessage): Replaced PeerMessageHandle with 
PeerMessage.
	(PeerInteraction): Replaced Peer with PeerHandle.
	Replaced Socket with SocketHandle.
	(addMessage): Replaced PeerMessage with PeerMessageHandle.
	(receiveMessage): Replaced PeerMessage with PeerMessageHandle.
	(receiveHandshake): Replaced HandshakeMessage with
	HandshakeMessageHandle.
	* src/PeerInteraction.cc
	(PeerInteraction): Replaced Peer with PeerHandle.
	Replaced Socket with SocketHandle.
	(~PeerInteraction): Removed the deallocation of the elements of
	messageQueue.
	(MsgPushBack::operator()): Replaced PeerMessage with 
PeerMessageHandle.
	(isSendingMessageInProgress): Replaced PeerMessage with
	PeerMessageHandle.
	(sendMessages): Use PeerMessageHandle. Removed try-catch block.
	(addMessage): Replaced PeerMessage with PeerMessageHandle.
	(rejectAllPieceMessageInQueue): Use PeerMessageHandle.
	(rejectPieceMessageInQueue): Use PeerMessageHandle.
	(abortPiece): Use PeerMessageHandle.
	(receiveHandshake): Replaced HandshakeMessage with
	HandshakeMessageHandle. Removed try-catch block.
	(createHandshakeMessage): Replaced HandshakeMessage with
	HandshakeMessageHandle.
	(receiveMessage): Replaced PeerMessage with PeerMessageHandle.
	Removed try-catch block.
	(createPeerMessage): Replaced PeerMessage with 
PeerMessageHandle.
	* src/HttpProxyResponseCommand.cc
	(HttpProxyRequestCommand): Replaced Socket with SocketHandle.
	* src/FtpTunnelResponseCommand.h
	(FtpTunnelResponseCommand): Replaced Socket with SocketHandle.
	* src/HttpConnection.cc
	(HttpConnection): Replaced Socket with SocketHandle.
	* src/PeerAbstractCommand.cc
	(PeerAbstractCommand): Replaced Socket with SocketHandle.
	(~PeerAbstractCommand): Removed the deallocation of socket.
	Use disableReadCheckSocket, disableWriteCheckSocket.
	(disableReadCheckSocket): New function.
	(setReadCheckSocket): Replaced Socket with SocketHandle.
	(disableWriteCheckSocket): New function.
	(setWriteCheckSocket): Replaced Socket with SocketHandle.
	* src/InitiateConnectionCommandFactory.h: Corrected indentation.
	* src/FtpTunnelRequestCommand.cc
	(FtpTunnelRequestCommand): Replaced Socket with SocketHandle.
	(~FtpTunnelRequestCommand): Corrected indentation.
	* src/DownloadCommand.h
	(DownloadCommand): Replaced Socket with SocketHandle.
	* src/PeerListenCommand.cc
	(PeerListenCommand): Removed the initialization of socket.
	(~PeerListenCommand): Removed the deallocation of socket.
	(bindPort): Use SocketHandle.
	(execute): Use SocketHandle and PeerHandle.
	* src/FtpDowndloadCommand.cc
	(FtpDownloadCommand): Replaced Socket with SocketHandle.
	(~FtpDownloadCommand): Removed the deallocation of ctrlSocket.
	* src/main.cc
	(main): Corrected indentation.
	* src/HttpInitiateConnectionCommand.cc
	(HttpInitiateConnectionCommand): Replaced Socket with 
SocketHandle.
	(executeInternal): Removed the allocation of socket.
	* src/HttpRequestCommand.h
	(HttpRequestCommand): Replaced Socket with SocketHandle.
	* src/FtpNegotiationCommand.h
	(dataSocket): Changed its type to SocketHandle.
	(serverSocket): Changed its type to SocketHandle.
	(FtpNegotiationCommand): Replaced Socket with SocketHandle.
	* src/TorrentMan.h
	(MAX_PEER_UPDATE): Removed.
	(MAX_PEERS): New definition.
	(Peers): The element is now of type PeerHandle.
	(addPeer): Replaced Peer with PeerHandle. Removed 'duplicate' 
argument.
	(getPeer): Replaced Peer with PeerHandle.
	(deleteOldErrorPeers): Removed.
	(deleteErrorPeer): New function.
	(hasMissingPiece): Replaced Peer with PeerHandle.
	(getMissingPieceIndex): Replaced Peer with PeerHandle.
	(getMissingPiece): Replaced Peer with PeerHandle.
	(getMissingFastPieceIndex): Replaced Peer with PeerHandle.
	(getMissingFastPiece): Replaced Peer with PeerHandle.
	(addActivePeer): Replaced Peer with PeerHandle.
	(deleteActivePeer): Replaced Peer with PeerHandle.
	Added a check for the return value of find.
	* src/FtpTunnelResponseCommand.cc
	(FtpTunnelResponseCommand): Replaced Socket with SocketHandle.
	* src/FtpInitiateConnectionCommand.cc
	(executeInternal): Removed the allocation of socket.
	* src/DownloadEngine.h
	(Sockets): An element is now of type SocketHandle.
	(SockCmdMap): A key is of type SocketHandle, a value is of type 
int.
	(CommandUuids): New type definition.
	(rsockets): Changed its type to SockCmdMap.
	(wsockets): Changed its type to SockCmdMap.
	(addSocket): Rewritten.
	(deleteSocket): Rewritten.
	(addSocketForReadCheck): Rewritten.
	(deleteSocketForReadCheck): Rewritten.
	(addSocketForWriteCheck): Rewritten.
	(deleteSocketForWriteCheck): Rewritten.
	(PairFind): New template class.
	* src/HttpDownloadCommand.h
	(HttpDownloadCommand): Replaced Socket with SocketHandle.
	* src/FtpConnection.cc
	(FtpConnection): Replaced Socket with SocketHandle.
	(sendPort): Removed the allocation of serverSocket. Removed 
try-catch
	block.
	* src/InitiateConnectionCommandFactory.cc
	(DlAbortEx.h): Included DlAbortEx.h.
	(createInitiateConnectionCommand): Throw exception if the 
protocol of
	requested URI is not supported.
	* src/Peer.cc
	(nullPeer): Changed its type to PeerHandle.
	(operator==): New function.
	(operator!=): New function.
	* src/Peer.h
	(SharedHandle.h): Included SharedHandle.h.
	(operator==): New function.
	(operator!=): New function.
	(Peer): Added the default constructor.
	Use resetStatus() to initialize member variables.
	(nullPeer): Removed.
	* src/TrackerUpdateCommand.cc
	(execute): Brushed up using SharedHandle. Replaced 
MAX_PEER_UPDATE
	with MIN_PEERS.
	* src/PeerListenCommand.h
	(socket): Changed its type to SocketHandle.
	* src/Command.h
	(CommandUuid): New type definition.
	(uuid): New variable.
	(uuidGen): New variable.
	(Command): Added the initialization of uuid.
	(getUuid): New function.
	* src/Socket.h
	(Socket): Removed.
	(SocketHandle): New type definition.
	* src/DownloadEngine.h
	(FindCommand): New function object.
	(run): The portion of socket check was rewritten.
	(SetDescriptor): New function object.
	(AccumulateActiveCommandUuid): New function object.
	(waitData): Rewritten.
	(addSocket): Rewritten.
	(deleteSocket): Rewritten.
	(addSocketForReadCheck): Rewritten.
	(addSocketForWriteCheck): Rewritten.
	(deleteSocketForReadCheck): Rewritten.
	(deleteSocketForWriteCheck): Rewritten.
	* src/HttpProxyResponseCommand.h
	(HttpProxyResponseCommand): Replaced Socket with SocketHandle.
	* src/HttpConnection.h
	(socket): Changed its type to SocketHandle.
	(HttpConnection): Replaced Socket with SocketHandle.
	* src/PeerInitiateConnectionCommand.cc
	(PeerInitiateConnectionCommand): Replaced Peer with PeerHandle.
	(executeInternal): Removed the allocation of socket.
	(prepareForNextPeer): Use PeerHandle.
	* src/PeerMessage.h
	(peer): Changed its type to PeerHandle.
	(getPeer): Replaced Peer with PeerHandle.
	(setPeer): Replaced Peer with PeerHandle.
	* src/DownloadCommand.cc
	(DownloadCommand): Replaced Socket with SocketHandle.
	* src/FtpConnection.h
	(socket): Changed its type to SocketHandle.
	(FtpConnection): Replaced Socket with SocketHandle.
	(sendPort); Replaced Socket with SocketHandle.
	* src/FtpDowndloadCommand.h
	(ctrlSocket): Changed its type to SocketHandle.
	(FtpDownloadCommand): Replaced Socket with SocketHandle.
	* src/HttpProxyRequestCommand.cc
	(HttpProxyRequestCommand): Replaced Socket with SocketHandle.
	* src/FtpTunnelRequestCommand.h
	(FtpTunnelRequestCommand): Replaced Socket with SocketHandle.
	
	etc
	
	* src/PeerChokeCommand.h
	(setAllPeerChoked): Removed.
	(setAllPeerResetDelta): Removed.
	* src/PeerChokeCommand.cc
	(setAllPeerChoked): Removed.
	(ChokePeer): New function object.
	(setAllPeerResetDelta): Removed.
	(ResetDelta): New function object.
	(orderByDownloadRate): Fixed a bug: use DowloadFaster, not 
UploadFaster
	(execute): Show download speed when the local node is a seeder.
	setAllPeerChoked and setAllPeerResetDelta were rewritten
	using STL.
	* src/TrackerWatcherCommand.h
	(MIN_PEERS): Removed.
	* src/TorrentMan.cc
	(getPeer): Replaced MAX_PEER_UPDATE with MIN_PEERS.
2006-07-19 17:07:45 +00:00
Tatsuhiro Tsujikawa
f15d41dd63 2006-07-06 18:31:58 +00:00
Tatsuhiro Tsujikawa
4745544046 2006-07-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To fix the bug that .aria2 file is not saved if downloading is 
stopped
	by the errors:it results that aria2 can not resume downloading:
	
	* src/main.cc
	(normalDownload): Added the call to save().
	(main): Added the deletion of the elements in 'reserved'.

	To fix log:

	* src/PeerInteraction.cc
	(receiveHandshake): Fixed log.

	To improve the download performance just a little bit:

	* src/TorrentMan.cc
	(getPeer): Return nullPeer if connections is greater than
	MAX_PEER_UPDATE.
2006-07-06 18:02:38 +00:00
Tatsuhiro Tsujikawa
9c84558fd8 2006-07-04 12:12:00 +00:00
Tatsuhiro Tsujikawa
39d27f9902 2006-07-04 12:04:47 +00:00
Tatsuhiro Tsujikawa
2c7ce13f89 Updated doc 2006-07-04 12:03:40 +00:00
Tatsuhiro Tsujikawa
fac88666ed 2006-07-04 11:47:56 +00:00
Tatsuhiro Tsujikawa
db35fe355a * src/main.cc:
Added ENABLE_MESSAGE_DIGEST to skip checksum checking when the 
message
	digest support is not available.
	* src/MetalinkEntry.cc
	(check): Added ENABLE_MESSAGE_DIGEST. Return true if the message 
digest
	support is not available.
2006-07-04 11:44:15 +00:00
Tatsuhiro Tsujikawa
31cf446f6d 2006-07-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To improve the conditional compilation:

	* src/MultiDiskWriter.h:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.	
	* src/MultiDiskWriter.cc:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	* src/Util.h:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	Added ENABLE_BITTORRENT around computeFastSet().
	* src/Util.cc:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	Added ENABLE_BITTORRENT around computeFastSet().	
	* src/messageDigest.h:
	Replaced ENABLE_BITTORRENT with ENABLE_SSL.
	* src/ShaVisitor.h:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	* src/ShaVisitor.cc:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	* src/main.cc:
	Added ENABLE_BITTORRENT around includes and blocks related to
	BitTorrent.
	* src/AbstractDiskWriter.h:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	* src/AbstractDiskWriter.cc:
	Replaced ENABLE_SHA1DIGEST with ENABLE_MESSAGE_DIGEST.
	
	To add command-line options for Metalink:

	* src/main.cc:
	Added metalink-version, metalink-language, metalink-os,
	follow-metalink.

	To use EXIT_SUCCESS and EXIT_FAILURE with exit():

	* src/main.cc: Use these definition.
2006-07-04 10:57:56 +00:00
Tatsuhiro Tsujikawa
8d340992d6 2006-07-03 14:19:59 +00:00
Tatsuhiro Tsujikawa
78eff23254 2006-07-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add Metalink support(http/ftp only):

	* src/AbstractCommand.h
	(tryReserved): New function.
	* src/AbstractCommand.cc
	(execute): Call tryReserved().
	(tryReserved): New function.
	* src/Request.h
	(Requests): New type definition.
	* src/SegmentMan.h
	(reserved): New variable.
	* src/Util.h
	(fileChecksum): New function.
	(toUpper): New function.
	(toLower): New function.
	* src/Util.cc
	(messageDigest.h): Included.
	(trim): Trim \r\n\t.
	(fileChecksum): New function.
	(toUpper): New function.
	(toLower): New function.
	* src/main.cc
	(normalDownload): New function.
	(main): Added 2 command-line options: metalink-file,
	metalink-connection. Their usage has not been written yet.
	* src/MetalinkProcessor.h: New class.
	* src/Xml2MetalinkProcessor.h: New class.
	* src/Xml2MetalinkProcessor.cc: New class.
	* src/MetalinkEntry.h: New class.
	* src/MetalinkEntry.cc: New class.
	* src/MetalinkResource.h: New class.
	* src/MetalinkResource.cc: New class.
	
	To add md5 message digest checking:

	* src/messageDigest.h: Rewritten.
	* src/MultiDiskWriter.cc: Updated according to the changes in
	messageDigest.h.
	* src/ShaVisitor.cc: Updated according to the changes in
	messageDigest.h.
	* src/Util.cc: Updated according to the changes in 
messageDigest.h.
	* src/AbstractDiskWriter.cc: Updated according to the changes in
	messageDigest.h.
	
	To fix a bug that causes segfault when the payload length in 
peer
	message is less than 0:

	* src/PeerConnection.cc:
	(receiveMessage): Fixed the bug.
	* src/PeerMessageUtil.cc
	(checkLength): Throw an exception if length is less than or 
equals to
	0.
	
	To add new interfaces to Base64 encoding/decoding:

	* src/Base64.h
	(part_encode): Changed the method signature.
	(encode): New function(overload).
	(decode): New function(overload).
	* src/Base64.cc
	(part_encode): Rewritten.
	(encode): Rewritten.
	(encode): New function(overload).

	To prevent a peer to download same piece if there is an error in
	checksum:

	* src/PieceMessage.cc
	(receivedAction): Call peerInteraction->abortPiece().
2006-07-03 14:19:23 +00:00
Tatsuhiro Tsujikawa
003a474357 2006-06-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/Util.cc
	(difftv): Added a cast to (long long int).
	* src/TorrentMan.cc
	(advertisePiece): Use push_front.
	(getAdvertisedPieceIndexes): A performance improvement was made.	
	* src/Time.h
	(getTimeInMicros): Added a cast to (long long int).
	(getTimeInMillis): Added a cast to (long long int).
2006-06-24 17:26:07 +00:00
Tatsuhiro Tsujikawa
722b3f8957 2006-06-25 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To fix the bug that causes same have message is sent many times 
to
	a single peer.

	* src/Time.cc
	(isNewer): Use Util::difftv().

	To fix the bug that sends tracker requests without a sleep 
interval
	when the number of connections is less than 15.

	* src/TrackerWatcherCommand.cc
	(execute): Now the number of connections is not a factor to 
decide
	whether or not a tracker request should be sent or not.
	* src/Time.h
	(setTimeInSec): New function.
	* src/Time.cc
	(setTimeInSec): New function.

	etc.
	
	* src/ChokeMessage.cc
	(receivedAction): Removed peer->snubbing = false

	* src/PeerConnection.h
	(receiveHandshake): Updated doc.

	* src/TorrentMan.h
	(getAdvertisedPieceIndexes): Updated the method signature.
	* src/TorrentMan.cc
	(getAdvertisedPieceIndexes): Updated the method signature.

	* Release 0.5.2
2006-06-24 16:09:14 +00:00
Tatsuhiro Tsujikawa
d02d80d9e9 2006-06-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To make a listening socket non-block:
	
	* src/SocketCore.h
	(setNonBlockingMode): New function.
	* src/SocketCore.cc
	(setNonBlockingMode): New function.
	(beginListen): Added a call to setNonBlockingMode().
	(acceptConnection): Call setNonBlockingMode().
	(setBlockingMode): Updated.

	To handle tracker's NAT-checking:
	
	* src/PeerConnection.cc
	(receiveHandshake): 'msg' param is filled with received data and
	its length is assigned to 'length' param, even if all handshake
	message is not yet received.
	* src/PeerInteractionCommand.cc
	(executeInternal): Use peerInteraction->receiveHandshake(true) 
when
	a new peer connects to localhost.
	A call to peerInteraction->sendHandshake() was removed because 
	it is called from peerInteraction->receiveHandshake(true).
	* src/PeerInteraction.h
	(quickReplied): New variable.
	(receiveHandshake): Added an argument.
	* src/PeerInteraction.cc
	(PeerInteraction): Added the initialization of quickReplied.
	(receiveHandshake): Send handshake message as soon as the info 
hash
	in a handshake message from a peer is correct.

	
	To change the random part of peer id and key parameter:

	* src/TorrentMan.h
	(key): New variable.
	* src/TorrentMan.cc
	(setupInternal1): Use Util::randomAlpha() to generate random 
part
	of peer id, which is now "-aria2-"+13 alphabet 
characters([A-Za-z]).
	key is also generated by Util::randomAlpha() and it is now 8 
character
	long.
	* src/Util.h
	(randomAlpha): New function.
	* src/Util.cc
	(randomAlpha): New function.
	* src/TrackerWatcherCommand.cc
	(execute): In a tracker request: Use torrentMan->key as key 
parameter.
	Added no_peer_id=1.
	
	Set snubbing flag to false when a choke message is received from 
a
	snubbed peer.

	* src/ChokeMessage.cc
	(receivedAction): Set snubbing flag to false.
2006-06-22 15:26:18 +00:00
Tatsuhiro Tsujikawa
70ff0c0b3b 2006-06-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/TorrentMan.cc (setupInternal1): Fixed peerId generation 
bug.

	* src/SimpleLogger.h (writeHeader): New function.
	* src/SimpleLogger.cc (writeHeader): New function.
	(writeLog): Fixed the bug that causes segfaults if exception 
message
	contains an unescaped "%" character.

	* src/TrackerWatcherCommand.cc (execute): Added a short sleep
	when a tracker request fails.

	* src/Request.cc (parseUrl): Query string is now handled 
properly.
2006-06-18 09:23:25 +00:00
Tatsuhiro Tsujikawa
d380b7b6ab 2006-06-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add Time class which represents a specific instant in time 
and
	its precision is microseconds. Time checking procedures were 
rewritten
	using this object.

	* src/Time.h: New class.
	* src/Time.cc: New class.
	* src/AbstractCommand.h
	(updateCheckPoint): Removed.
	(isTimeoutDetected): Removed.
	(checkPoint): Changed the type to Time.
	(timeout): New variable.
	(setTimeout): New function.
	* src/AbstractCommand.cc
	(AbstractCommand): Removed the initialization of checkPoint.
	Added the initialization of timeout.
	(updateCheckPoint): Removed.
	(isTimeoutDetected): Removed.
	(execute): Use checkPoint.reset() and checkPoint.elapsed().
	* src/PeerChokeCommand.h
	(checkPoint): Changed the type to Time.
	* src/PeerChokeCommand.cc
	(PeerChokeCommand): Removed the initialization of checkPoint.
	(execute): Rewritten using Time object.
	* src/TrackerWatcherCommand.h
	(checkPoint): Changed the type to Time.
	* src/TrackerWatcherCommand.cc
	(TrackerWatcherCommand): Removed the initialization of 
checkPoint.
	(execute): Rewritten.
	* src/ConsoleDownloadEngine.h
	(cp): Changed the type to Time.
	(startup): Changed the type to Time.
	* src/ConsoleDownloadEngine.cc
	(initStatistics): Use cp.reset(), startup.reset().
	(calculateStatistics): Rewritten using Time object.
	* src/PeerAbstractCommand.h
	(updateCheckPoint): Removed.
	(isTimeoutDetected): Removed.
	(checkPoint): Changed the type to Time.
	* src/PeerAbstractCommand.cc
	(PeerAbstractCommand): Removed the initialization of checkPoint.
	(updateCheckPoint): Removed.
	(isTimeoutDetected): Removed.
	(execute): Use checkPoint.reset() and checkPoint.elapsed().
	* src/PeerInteractionCommand.cc
	(PeerInteractionCommand): Removed the initializations of struct
	timeval variables.
	* src/PeerInteractionCommand.h
	(keepAliveCheckPoint): Changed the type to Time.
	(chokeCheckPoint): Changed the type to Time.
	(freqCheckPoint): Changed the type to Time.
	(haveCheckTime): Changed the type to Time.
	* src/PeerInteractionCommand.cc
	(executeInternal): Rewritten using Time object.
	(detectMessageFlooding): Rewritten using Time object.
	(checkLongTimePeerChoking): Rewritten using Time object.
	(sendKeepAlive): Rewritten using Time object.
	(checkHave): Rewritten using Time object.
	* src/SleepCommand.h
	(checkPoint): Changed the type to Time.
	* src/SleepCommand.cc
	(SleepCommand): Removed the initialization of checkPoint.
	(execute): Rewritten using Time object.
	* src/TorrentAutoSaveCommand.h
	(checkPoint): Changed the type to Time.
	* src/TorrentAutoSaveCommand.cc
	(TorrentAutoSaveCommand): Removed the initialization of 
checkPoint.
	(execute): Rewritten.
	* src/DownloadCommand.h
	(sw): Changed the type to Time.
	* src/DownloadCommand.cc
	(DownloadCommand): Removed the initialization of sw.
	(executeInternal): Rewritten.
	* src/RequestSlot.h
	(dispatchedTime): Changed the type to Time.
	* src/RequestSlot.cc
	(RequestSlot): Removed the call to setDispatchedTime().
	(setDispatchedTime): Rewirtten.
	(isTimeout): Rewritten.
	(getLatencyInMillis): Rewritten.
	* src/TorrentDownloadEngine.h
	(cp): Changed the type to Time[2].
	(startup): Changed the type to Time.
	* src/TorrentDownloadEngine.cc
	(initStatistics): Rewritten.
	(calculateStatistics): Rewritten.
	* src/DownloadEngine.cc
	(run): Rewritten.
	
	To detect all attempts to connect to the tracker are failed:

	* src/AbstractCommand.cc
	(execute): Increment e->segmentMan->errors if a command aborted.
	* src/SegmentMan.h
	(errors): New variable.
	* src/SegmentMan.cc
	(SegmentMan): Added the initialization of errors.
	(init): Added the initialization of errors.
	* src/TrackerWatcherCommand.cc
	(execute): If e->segmentMan->errors > 0 then assume that the 
tracker
	request was failed.
	
	To handle snubbed peers:
	
	* src/PeerChokeCommand.cc
	(optUnchokingPeer): Snubbed peers don't get unchoked.
	(execute): Snubbed peers don't get unchoked.
	* src/PeerInteraction.h
	(REQUEST_TIME_OUT): Changed the value from 120 to 60.
	* src/PeerInteraction.cc
	(checkRequestSlot): A peer get marked as "snubbed" if it doesn't 
send
	back the requested 16k block in 60 seconds.
	* src/PieceMessage.cc
	(receivedAction): A peer's snubbed state is cleard if it sends
	the requested 16k block in 60 seconds.
	* src/Peer.h
	(snubbing): New variable.
	* src/Peer.cc
	(resetStatus): Added snubbed = false.
	
	To fix the bug that causes have message is not sent:

	* src/PeerInteractionCommand.cc
	(~PeerInteractionCommand): Removed 
e->torrentMan->unadvertisePiece().
	(FLOODING_CHECK_INTERVAL): New definition(temporal).
	(detectMessageFlooding): Use FLOODING_CHECK_INTERVAL.
	* src/TorrentMan.h
	(HaveEntry): New class.
	(advertisePiece): Rewritten.
	(getAdvertisedPieceIndexes): Rewritten.
	(Haves): Changed the type.
	(getAdvertisedPieceIndexes): Added an argument.
	
	Others:
	
	* src/TorrentMan.h
	(DEFAULT_ANNOUNCE_INTERVAL): Changed the value to 1800.
	(DEFAULT_ANNOUNCE_MIN_INTERVAL): Changed the value to 1800.
	* src/TorrentMan.cc
	(getPeer): Don't check the number of connections here.
	(setupInternal1): Changed peerId.

	* src/PeerInteractionCommand.h
	(KEEP_ALIVE_INTERVAL): New definition.
	(sendKeepAlive): Use KEEP_ALIVE_INTERVAL.

	* src/main.cc
	(main): SA_ONESHOT was replaced with SA_RESETHAND.

	* src/DownloadEngine.h: Removed unnecessary header includes.
2006-06-12 16:55:08 +00:00
Tatsuhiro Tsujikawa
7e36107f45 2006-05-29 14:56:55 +00:00
Tatsuhiro Tsujikawa
7774b6330c 2006-05-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To fix the bug that cause segfaults if a zero-length peer list 
is
	a zero-length list:
	
	* src/TrackerUpdateCommand.cc
	(execute): Added a check to see wether the type of peers is 
Data*.
2006-05-29 14:36:25 +00:00
Tatsuhiro Tsujikawa
3dcbda0676 2006-05-27 08:24:09 +00:00
Tatsuhiro Tsujikawa
d9c029db45 * src/CancelMessage.h
(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/RejectMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/SuggestPieceMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/AllowedFastMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/PortMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/HaveNoneMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/KeepAliveMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/HaveAllMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/UnchokeMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/BitfieldMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/PieceMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/RequestMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/NotInterestedMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/ChokeMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/InterestedMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
	* src/HaveMessage.h
	(ID): Renamed as ID_t
	(ID_t): New enum.
2006-05-27 08:12:23 +00:00
Tatsuhiro Tsujikawa
ef729423fb 2006-05-26 15:34:05 +00:00
Tatsuhiro Tsujikawa
97614b3281 2006-05-26 15:28:54 +00:00
Tatsuhiro Tsujikawa
ca5e332df9 2006-05-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/PeerAbstractCommand.h
	(beforeSocketCheck): Removed.
	* src/PeerAbstractCommand.cc
	Modified in order to call executeInternal() even if socket check
	and upload limit check fail.
	* src/PeerInteractionCommand.h
	(keepAlive): Removed.
	(sendKeepAlive): New function.
	(checkHave): New function.
	(beforeSocketCheck): Removed.
	* src/PeerInteractionCommand.cc
	(executeInternal): Use peerInteraction->checkRequestSlot(). 
Added
	calls to checkHave() and sendKeepAlive().
	(keepAlive): Renamed to sendKeepAlive().
	(sendKeepAlive): New function.
	(beforeSocketCheck): Removed.
	(checkHave): New function.
	* src/BitfieldMan.cc
	(getMissingIndex): Don't call getMissingIndexRandomly() if max 
is 0.
	(getMissingUnusedIndex): Don't call getMissingIndexRandomly() if 
max is
	0.
	(getMissingIndex): Dont't call getMissingIndexRandomly() if max 
is 0.
	* src/TorrentMan.h
	(UsedPieces): Removed.
	(Pieces): New type definition.
	* src/Piece.h: Updated doc.
	* src/Peer.h
	(totalLength): Removed.
	* src/Peer.cc
	(updateLatency): Fixed the latency calculation.
	* src/TorrentMan.cc
	(addPeer): Call deleteOldErrorPeers() only if peers.size() is 
higher
	than or equal to MAX_PEER_LIST_SIZE.
	If duplicate is false and peer.size() >= MAX_PEER_LIST_SIZE,
	then return false.
	(deleteOldErrorPeers): Rewritten.
	(deleteUsedPiece): Fixed the miss use of STL remove.
	* src/PeerInteraction.h
	(Pieces): Removed.
	(deleteTimeoutRequestSlot): Removed.
	(deleteCompletedRequestSlot): Removed.
	(checkRequestSlot): New function.
	* src/PeerInteraction.cc
	(deleteTimeoutRequestSlot): Merged to checkRequestSlot().
	(deleteCompletedRequestSlot): Merged to checkRequestSlot().
	(checkRequestSlot): New function.
	* src/DownloadEngine.cc
	(run): Clear activeSockets before calling waitData().
	(waitData): Removed a call to activeSockets.clear().
2006-05-26 15:28:19 +00:00
Tatsuhiro Tsujikawa
b72c6805e4 2006-05-24 16:08:00 +00:00
Tatsuhiro Tsujikawa
0411de9271 2006-05-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To attempt to handle EINTR:
	
	* src/SocketCore.cc
	(isReadable): Added EINTR handling.
	(isWritable): Added EINTR handling.

	To improve the performance:
	
	* src/AbstractCommand.cc
	(isTimeoutDetected): Use Util::difftvsec() instead of 
Util::difftv().
	* src/PeerInteractionCommand.h
	(receiveMessage): Renamed as receiveMessages().
	(receiveMessages): New function.
	* src/PeerInteractionCommand.cc
	(executeInternal): receiveMessage loop is moved to new 
receiveMessages
	() function. detectMessageFlooding() is moved here.
	(detectMessageFlooding): Use Util::difftvsec() instead of 
Util::difftv
	(). The flooding detection for have message is comment out.
	(checkLongTimePeerChoking): Use Util::difftvsec() instead of
	Util::difftv().
	(receiveMessage): Renamed as receiveMessages().
	(receiveMessages): New function.
	(keepAlive): Use Util::difftvsec() instead of Util::difftv().
	(beforeSocketCheck): Commented out checkLongTimePeerChoking().
	* src/SleepCommand.cc
	(execute): Use Util::difftvsec() instead of Util::difftv().
	* src/BitfieldMan.h
	(getNthBitIndex): New function.
	(hasMissingPiece): New function.
	(getAllMissingIndexes): New function.
	* src/BitfieldMan.cc
	(countSetBit): Rewritten.
	(getNthBitIndex): New function.
	(getMissingIndexRandomly): Rewritten.
	(hasMissingPiece): New function.
	(getAllMissingIndexes): New function.
	* src/TorrentMan.cc
	(hasMissingPiece): New function.
	(deleteUsedPiece): Rewritten using STL.
	* src/PeerInteraction.cc
	(getNewPieceAndSendInterest): Use TorrentMan::hasMissingPiece(), 
which
	is a little bit faster then TorrentMan::getMissingPieceIndex().
	(addRequests): Updated the number of pending requests.
	* src/PeerAbstractCommand.cc
	(isTimeoutDetected): Use Util::difftvsec() instead of 
Util::difftv().
	(execute): Returns true if TorrentMan::isHalt() is true.
	Corrected the condition of upload limit checking.
	* src/Util.h
	(countBit): New function.
	* src/Util.cc
	(nbits): New variable.
	(countBit): New function.
	* src/DownloadEngine.h
	(SockCmdMap): New type definition.
	(waitData): Added an argument.
	(addSocket): Added an argument.
	(addSocketForReadCheck): Added an argument.
	(addSocketForWriteCheck): Added an argument.
	* src/DownloadEngine.cc
	(run): Executes only commands whose sockets are ready to read or 
write.
	All commands are executed in every 1 second.
	(waitData): Calls select() again if it returned
	EINTR.
	(addSocket): Saves socket and command object pair to the map.
	(deleteSocket): Deletes socket and command object pair from the 
map.
	(addSocketForReadCheck): Added an argument.
	(addSocketForWriteCheck): Added an argument.
	* src/DownloadCommand.cc
	(executeInternal): Use Util::difftvsec() instead of 
Util::difftv().
	
	To send "event=stopped" to the tracker when the application 
finishes:
	
	* src/PeerChokeCommand.h
	(checkPoint): New variable.
	* src/PeerChokeCommand.cc
	(PeerChokeCommand): Added the initialization of checkPoint.
	(execute): The interval check is now done by checkPoint, not
	SleepCommand. Return true if TorrentMan::isHalt() is true.
	* src/TorrentMan.h
	(halt): New function.
	(hasMissingPiece): New function.
	(isHalt): New function.
	(setHalt): New function.
	* src/TorrentMan.cc
	(TorrentMan): Added the initialization of halt.
	* src/TorrentAutoSaveCommand.h
	(checkPoint): New variable.
	* src/PeerListenCommand.cc
	(execute): Returns true if TorrentMan::isHalt() is true.
	* src/main.cc
	(setSignalHander): Added flags argument.
	(torrentHandler): Just calls TorrentMan::setHalt(true) and 
returns.
	(main): Set SA_ONESHOT flag of the signal hander of SIGINT and 
SIGTERM.
	Removed printDownloadAbortMessage() after torrent downloading 
loop.
	* src/TorrentAutoSaveCommand.cc
	(TorrentAutoSaveCommand): Added the initialization of 
checkPoint.
	(execute): Returns true if TorrentMan::isHalt() is true.
	The interval check is now done by checkPoint, not SleepCommand.
	* src/TrackerWatcherCommand.cc
	(execute): If TorrentMan::isHalt(), then create a tracker 
request with
	event=stopped.
	* src/TrackerUpdateCommand.cc
	(prepareForRetry): Do not use SleepCommand here.
	(execute): Returns true if TorrentMan::isHalt() is true.
	
	Others:
	
	* src/TorrentMan.cc
	(getMissingPieceIndex): Updated log message.
	* src/PeerInteraction.cc
	(createPeerMessag): Updated log message.
2006-05-24 15:18:58 +00:00
Tatsuhiro Tsujikawa
896ca193e0 2006-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the ability to download several pieces in mix in a 
command and
	increase the number of request slots according to request-cancel
	latency:
	
	* src/PeerInteractionCommand.cc
	(executeInternal): The number of messages to be received at a 
time
	is increased from 10 to 50.
	* src/LogFactory
	(getInstance): Added NullLogger.
	* src/NullLogger.h: New class.
	* src/BitfieldMan.h
	(getMissingIndex): New function.
	* src/BitfieldMan.cc
	(getMissingIndex): New function.
	* src/TorrentMan.h
	(checkOutPiece): New function.
	(getMissingPieceIndex): New function.
	(getMissingFastPieceIndex): New function.
	(getMissingFastPiece): New function.
	* src/TorrentMan.cc
	(updatePiece): Rewritten using STL.
	(syncPiece): Rewritten using STL.
	(getMissingPiece): Rewritten using getMissingPieceIndex() and
	checkOutPiece().
	(getMissingPieceIndex): New function.
	(getMissingFastPieceIndex): New function.
	(getMissingFastPiece): New function.
	(checkOutPiece): New function.
	* src/PeerInteraction.h
	(Pieces): New type definition.
	(piece): Removed.
	(pieces): New variable.
	(getNewPieceAndSendInterest): Added the "piece" argument.
	(abortPiece): Added the "piece" argument.
	(abortAllPieces): New function.
	(isInRequestSlot): New function.
	(hasDownloadPiece): Added the "index" argument.
	(setDownloadPiece): Removed.
	(getDownloadPiece): Added the "index" argument.
	(updatePiece): New function.
	(createRequestMessage): Added the "index" argument.
	* src/PeerInteraction.cc
	(onChoked): Rewritten.
	(abortPiece): Rewirtten.
	(abortAllPieces): New function.
	(deleteTimeoutRequestSlot): Rewritten.
	Clarified code a little bit.
	(deleteCompletedRequestSlot): Rewritten.
	(isInRequestSlot): New function.
	(syncPiece): Rewritten.
	(updatePiece): New function.
	(getNewPieceAndSendInterest): Rewritten.
	(addRequests):  Rewritten.
	(getDownloadPiece): Rewritten.
	(hasDownloadPiece): Rewritten.
	(createRequestMessage): Added the "index" argument.
	* src/common.h
	(BITFIELD_LEN_FROM_PIECES): Enclosed the variable in 
parentheses.
	(DIV_FLOOR): New definition.
	* src/PieceMessage.cc
	(receivedAction): Update request-piece latency here.
	* src/RequestSlot.h
	(getLatencyInMillis): New function.
	* src/RequestSlot.cc
	(isTimeout): Rewritten using getLatencyInMillis.
	(getLatencyInMillis): New function.
	* src/Piece.h
	(operator==): New function.
	(getMissingBlockIndex): New function.
	* src/Piece.cc
	(operator==): New function.
	(getMissingBlockIndex): New function.
	* src/Peer.h
	(DEFAULT_LATENCY): New definition.
	(latency): New variable.
	(updateLatency): New function.
	(getLatency): New function.
	* src/Peer.cc
	(resetStatus): Reset latecy.
	(updateLatency): New function.
2006-05-21 16:19:17 +00:00
Tatsuhiro Tsujikawa
6497ed63d4 2006-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/SocketCore.cc
	(isReadable): Added secure to the condition.
	* src/HttpConnection.cc
	(receiveResponse): Fixed a bug that causes no response header
	exception.
	* src/Peer.h
	(getFastSet): Fixed the return value type.
2006-05-19 15:49:32 +00:00
Tatsuhiro Tsujikawa
d018b3a609 2006-05-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To remove a wait from download loop:

	* src/DownloadEngine.cc
	(run): Comment out shortSleep.
	
        To rewrite the message handling:
	
	* src/CancelMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/CancelMessage.cc
	(create): New function.
	(receivedAction): Replaced deleteRequestMessageInQueue with
	rejectPieceMessageInQueue.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/BitfieldMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(msgLength): New variable.
	(~BitfieldMessage): Deleted msg.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/BitfieldMessage.cc
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/ChokeMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(sendPredicate): New function.
	(onSendComplete): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	(create): New function.
	* src/ChokeMessage.cc
	(create): New function.
	(send): Removed.
	(sendPredicate): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(onSendComplete): New function.
	* src/KeepAliveMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.	
	* src/KeepAliveMessage.cc
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/PortMessage.h
	(create): New function.
	(receivedAction): Updated log message.
	* src/PortMessage.cc: New file.
	* src/UnchokeMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(sendPredicate): New function.
	(onSendComplete): New function.
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/UnchokeMessage.cc
	(create): New function.
	(send): Removed.
	(sendPredicate): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(onSendComplete): New function.
	* src/PieceMessage.h
	(leftPieceDataLength): Removed.
	(leftDataLength): New variable.
	(headerSend): New variable.
	(pendingCount): New variable.
	(msgHeader): New variable.
	(sendPieceData): New function.
	(incrementPendingCount): New function.
	(isPendingCountMax): New function.
	(create): New function.
	(getMessageHeader): New function.
	(getMessageHeaderLength): New function.
	* src/PieceMessage.cc
	(create): New function.
	(getMessageHeader): New function.
	(getMessageHeaderLength): New function.
	(send): Rewritten.
	(sendPieceData): New function.
	* src/HaveMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(create): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/HaveMessage.cc
	(create): New function.
	(send): Removed.
	(sendPieceData): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/RequestMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/RequestMessage.cc
	(create): New function.
	(receivedAction): Added the handling of fast extension.
	Deleted torrentMan->addUploadLength, 
torrentMan->addDeltaUploadLength.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/InterestedMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(sendPredicate): New function.
	(onSendComplete): New function.
	(create): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/InterestedMessage.cc
	(create): New function.
	(send): Removed.
	(sendPieceData): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(onSendComplete): New function.
	* src/NotInterestedMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(sendPieceData): New function.
	(onSendComplete): New function.
	(create): New function.
	(send): Removed.
	(getMessage): New function.
	(getMessageLength): New function.
	* src/NotInterestedMessage.cc
	(create): New function.
	(send): Removed.
	(sendPredicate): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(onSendComplete): New function.
	* src/AllowedFastMessage.h: New class.
	* src/AllowedFastMessage.cc: New class.
	* src/RejectMessage.h: New class.
	* src/RejectMessage.cc: New class.
	* src/SuggestPieceMessage.h: New class.
	* src/SuggestPieceMessage.cc: New class.
	* src/HaveAllMessage.h: New class.
	* src/HaveAllMessage.cc: New class.
	* src/HaveNoneMessage.h: New class.
	* src/HaveNoneMessage.cc: New class.
	* src/HandshakeMessage.h: Derived from SimplePeerMessage.
	(msg): New variable.
	(reserved): New variable.
	(create): New function.
	(getId): New function.
	(receivedAction): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(isFastExtensionSupported): New function.
	* src/HandshakeMessage.cc
	(HandshakeMessage): Moved here from HandshakeMessage.h.
	(create): New function.
	(getMessage): New function.
	(getMessageLength): New function.
	(toString): Added the output of reserved field.
	(check): Added const qualifier.
	(isFastExtensionSupported): New function.
	* src/PeerMessageUtil.h
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createHaveMessage): Removed.
	(createBitfieldMessage): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createPortMessage): Removed.
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createHaveMessage): Removed.
	(createBitfieldMessage): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createKeepAliveMessage): Removed.
	(createHandshakeMessage): Removed.
	(setIntParam): New function.
	(createPeerMessageString): New function.
	* src/PeerMessageUtil.cc
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createHaveMessage): Removed.
	(createBitfieldMessage): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createPortMessage): Removed.
	(createRequestMessage): Removed.
	(createCancelMessage): Removed.
	(createPieceMessage): Removed.
	(createHaveMessage): Removed.
	(createChokeMessage): Removed.
	(createUnchokeMessage): Removed.
	(createInterestedMessage): Removed.
	(createNotInterestedMessage): Removed.
	(createBitfieldMessage): Removed.
	(createKeepAliveMessage): Removed.
	(createHandshakeMessage): Removed.
	(setIntParam): New function.
	(createPeerMessageString): New function.
	* src/PeerConnection.h
	(peer): Removed.
	(torrentMan): Removed.
	(createNLengthMessage): Removed.
	(setIntParam): Removed.
	(writeOutgoingMessageLog): Removed all overloaded functions.
	(PeerConnection): Deleted peer and torrentMan from its 
arguments.
	(sendMessage): New function.
	(sendHandshake): Removed.
	(sendKeepAlive): Removed.
	(sendChoke): Removed.
	(sendUnchoke): Removed.
	(sendInterested): Removed.
	(sendNotInterested): Removed.
	(sendHave): Removed.
	(sendBitfield): Removed.
	(sendRequest): Removed.
	(sendPiece): Removed.
	(sendPieceHeader): Removed.
	(sendPieceData): Removed.
	(sendCancel): Removed.
	(getPeer): Removed.
	* src/PeerConnection.cc
	(PeerConnection): Deleted peer and torrentMan from its 
arguments.
	(sendHandshake): Removed.
	(sendKeepAlive): Removed.
	(createNLengthMessage): Removed.
	(setIntParam): Removed.
	(writeOutgoingMessageLog): Removed all overloaded functions.
	(sendChoke): Removed.
	(sendUnchoke): Removed.
	(sendInterested): Removed.
	(sendNotInterested): Removed.
	(sendHave): Removed.
	(sendBitfield): Removed.
	(sendRequest): Removed.
	(sendPiece): Removed.
	(sendPieceHeader): Removed.
	(sendPieceData): Removed.
	(sendMessage): New function.
	(sendCancel): Removed.
	* src/PeerInteractionCommand.cc
	(PeerInteractionCommand): Call setUploadLimit.
	(executeInternal): Call setUploadLimit.
	Added the handling of "inProgress" state of handshake message.
	Call sendBitfield() or sendAllowdFast() instead of deprecated
	sendNow().
	(keepAlive): Call addMessage and sendMessage instead of 
deprecated
	sendNow().
	(beforeSocketCheck): Call addMessage instead of deprecated 
trySendNow()
	* src/TorrentMan.h
	(PEER_ID_LENGTH): New definition.
	(hasAllPieces): New function.
	* src/TorrentMan.cc
	(getMissingPiece): Added the handling of fast extension.
	(cancelPiece): Call updatePiece().
	(hasAllPieces): New function.
	* src/PeerInteraction.h
	(fastSet): New variable.
	(getNewPieceAndSendInterest): Changed the return type to void.
	(send): Renamed as sendMessages.
	(deleteAllRequestSlot): Removed.
	(deleteRequestMessageInQueue): Renamed as 
rejectPieceMessageInQueue.
	(cancelAllRequest): Removed all overloaded functions.
	(deleteAllRequestSlot): Removed.
	(deletePieceMessageInQueue): Renamed as 
rejectAllPieceMessageInQueue.
	(rejectPieceMessageInQueue): New function.
	(rejectAllPieceMessageInQueue): New function.
	(onChoked): New function.
	(isSendingMessageInProgress): New function.
	(getCorrespondingRequestSlot): Changed its arguments.
	(isInFastSet): New function.
	(addFastSetIndex): New function.
	(addRequests): New function.
	(sendNow): Removed.
	(trySendNow): Removed.
	(sendBitfield): New function.
	(sendAllowdFast): New function.
	(createHaveAllMessage): New function.
	(createHaveNoneMessage): New function.
	(createRejectMessage): New function.
	(createAllowedFastMessage): New function.
	* src/PeerInteraction.cc
	(send): Renamed as sendMessages.
	(sendMessages): New function.
	(MsgPushBack): New class.
	(isSendingMessageInProgress): New function.
	(deletePieceMessageInQueue): Renamed as 
rejectAllPieceMessageInQueue.
	(rejectAllPieceMessageInQueue): New function.
	Added the handling of fast extension.
	(deleteRequestMessageInQueue): Renamed as 
rejectPieceMessageInQueue.
	(rejectPieceMessageInQueue): New function.
	Added the handling of fast extension.
	(deleteRequestSlot): Replaced for loop with  std::find.
	(onChoked): New function.
	(deleteAllRequestSlot): Removed.
	(abortPiece): Rewirtten.
	(deleteTimeoutRequestSlot): Updated log messages.
	(getCorrespondingRequestSlot): Changed its arguments.
	(cancelAllRequest): Removed all overloaded functions.
	(receiveHandshake): Added the check to see whether an incoming 
peer
	supports fast extension.
	(createHandshakeMessage): Use HandshakeMessage::create instead 
of
	PeerMessageUtil.
	(createPeerMessage): Use create() of each message class instead 
of
	PeerMessageUtil.
	HaveAllMessage, HaveNoneMessage, RejectMessage, 
SuggestPieceMessage,
	AllowedFastMessage were added.
	(getNewPieceAndSendInterest): Changed its return value type to 
void.
	Added the handling of fast extension.
	(addRequests): New function.
	(sendNow): Removed.
	(sendHandshake): Rewritten.
	(trySendNow): Removed.
	(sendBitfield): New function.
	(sendAllowdFast): New function.
	(isInFastSet): New function.
	(addFastSetIndex): New function.
	(createRequestMessage): Use RequestMessage::create instead of
	PeerMessageUtil.
	(createCancelMessage): Use CancelMessage::create instead of
	PeerMessageUtil.
	(createPieceMessage): Use PieceMessage::create instead of
	PeerMessageUtil.
	(createHaveMessage): Use HaveMessage::create instead of
	PeerMessageUtil.
	(createChokeMessage): Use ChokeMessage::create instead of
	PeerMessageUtil.
	(createUnchokeMessage): Use UnchokeMessage::create instead of
	PeerMessageUtil.
	(createInterestedMessage): Use InterestedMessage::create instead 
of
	PeerMessageUtil.
	(createNotInterestedMessage): Use NotInterestedMessage::create 
instead
	of PeerMessageUtil.
	(createBitfieldMessage): Use BitfieldMessage::create instead of
	PeerMessageUtil.
	(createKeepAliveMessage): Use KeepAliveMessage::create instead 
of
	PeerMessageUtil.
	(createHaveAllMessage): New function.
	(createHaveNoneMessage): New function.
	(createRejectMessage): New function.
	(createAllowedFastMessage: New function.
	* src/Util.h
	(sha1Sum): New function.
	(computeFastSet): New function.
	* src/Util.cc
	(sha1Sum): New function.
	(computeFastSet): New function.
	* src/Peer.h
	(fastExtensionEnabled): New variable.
	(fastSet): New variable.
	(setAllBitfield): New function.
	(setFastExtensionEnabled): New function.
	(isFastExtensionEnabled): New function.
	(addFastSetIndex): New function.
	(getFastSet): New function.
	(isInFastSet): New function.
	(countFastSet): New function.
	* src/Peer.cc
	(isInFastSet): New function.
	(addFastSetIndex): New function.
	(setAllBitfield): New function.
	
	* src/AbstractCommand.cc (execute): Changed the procedure of 
checking
	sockets.
	* src/PeerAbstractCommand.cc
	(PeerAbstractCommand): Added the initialization for 
uploadLimitCheck
	and uploadLimit.
	(execute): Changed the procedure of checking sockets. The upload 
speed
	checking were added.
	(setUploadLimit): New function.
	(setUploadLimitCheck): New function.
	* src/PeerAbstractCommand.h
	(setUploadLimit): New function.
	(setUploadLimitCheck): New function.
	(uploadLimit): New variable.
	(uploadLimitCheck): New variable.

	To contact a tracker regularly:
	
	* src/TrackerWatcherCommand.h (interval): New variable.
	(checkPoint): New variable.
	(TrackerWatcherCommand): Added interval argument.
	* src/TrackerWatcherCommand.cc
	(TrackerWatcherCommand): Initialized checkPoint.
	(execute): Now a tracker is contacted in every specified period.
	If peer list is not needed, send request with numwant=0.

	* src/TrackerUpdateCommand.cc
	(execute): Updated log messages.

	* src/DownloadEngine.cc
	(~DownloadEngine): Removed two asserts.
	(waitData): Uncommented wfds. May be a bug fix.
2006-05-18 17:08:29 +00:00
Tatsuhiro Tsujikawa
bd5d11da3c * src/SendMessageQueue.h: Renamed to PeerInteraction.h
* src/SendMessageQueue.cc: Renamed to PeerInteraction.cc
	* src/PeerInteraction.h: New class.
	* src/PeerInteraction.cc: New class.
2006-05-10 13:10:51 +00:00
Tatsuhiro Tsujikawa
ef6c1d53a3 * src/PeerInteractionCommand.h
(checkInactiveConnection): Removed.
	* src/PeerInteractionCommand.cc
	(executeInternal): Removed following function calls:
	detectMessageFlooding(), checkLongTimePeerChoking and
	checkInactiveConnection().
	(checkInactiveConnection): Removed.
	(detectMessageFlooding): Removed function call to
	checkInactiveConnection().

	* src/PeerMessageUtil.h
	(createChokeMessage): New function. Overload.
	(createUnchokeMessage): New function. Overload.
	(createInterestedMessage): New function. Overload.
	(createNotInterestedMessage): New function. Overload.
	(createHaveMessage): New function. Overload.
	(createBitfieldMessage): New function. Overload.
	(createRequestMessage): New function. Overload.
	(createCancelMessage): New function. Overload.
	(createPieceMessage): New function. Overload.
	(createKeepAliveMessage): New function. Overload.
	* src/PeerMessageUtil.cc
	(createChokeMessage): New function. Overload.
	(createUnchokeMessage): New function. Overload.
	(createInterestedMessage): New function. Overload.
	(createNotInterestedMessage): New function. Overload.
	(createHaveMessage): New function. Overload.
	(createBitfieldMessage): New function. Overload.
	(createRequestMessage): New function. Overload.
	(createCancelMessage): New function. Overload.
	(createPieceMessage): New function. Overload.
	(createKeepAliveMessage): New function. Overload.

	* src/SendMessageQueue.cc
	(createRequestMessage): Use PeerMessageUtil.
	(createCancelMessage): Use PeerMessageUtil.
	(createPieceMessage): Use PeerMessageUtil.
	(createHaveMessage): Use PeerMessageUtil.
	(createChokeMessage): Use PeerMessageUtil.
	(createUnchokeMessage): Use PeerMessageUtil.
	(createInterestedMessage): Use PeerMessageUtil.
	(createNotInterestedMessage): Use PeerMessageUtil.
	(createBitfieldMessage): Use PeerMessageUtil.
	(createKeepAliveMessage): Use PeerMessageUtil.
2006-05-10 12:30:26 +00:00
Tatsuhiro Tsujikawa
ebfdbefb7f 2006-05-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Each peer message has its own class.
	
	* src/PendingMessages.h: Removed.
	* src/PendingMessages.cc: Removed. The sending process was moved 
to
	each message class.
	* src/RequestSlotMan.h: Removed.
	* src/RequestSlotMan.cc: Removed. All functionarities were moved 
to
	SendMessageQueue.
	* src/RequestMessage.h: New class.
	* src/RequestMessage.cc: New class.
	* src/CancelMessage.h: New class.
	* src/CancelMessage.cc: New class.
	* src/BitfieldMessage.h: New class.
	* src/BitfieldMessage.cc: New class.
	* src/ChokeMessage.h: New class.
	* src/ChokeMessage.cc: New class.
	* src/KeepAliveMessage.h: New class.
	* src/KeepAliveMessage.cc: New class.
	* src/PortMessage.h: New class.
	* src/UnchokeMessage.h: New class.
	* src/UnchokeMessage.cc: New class.
	* src/PieceMessage.h: New class.
	* src/PieceMessage.cc: New class.
	* src/HaveMessage.h: New class.
	* src/HaveMessage.cc: New class.
	* src/BitfieldMessage.h: New class.
	* src/BitfieldMessage.cc: New class.
	* src/NotInterestedMessage.h: New class.
	* src/NotInterestedMessage.cc: New class.
	* src/InterestedMessage.h: New class.
	* src/InterestedMessage.cc: New class.
	* src/HandshakeMessage.h (sendMessageQueue): New variable.
	(getSendMessageQueue): New function.
	(setSendMessageQueue): New function.
	* src/HandshakeMessage.cc: New class.
	* src/PeerConnection.h (receiveMessage): Changed return value 
and
	arguments.
	(receiveHandshake): Changed return value and arguments.
	* src/PeerConnection.cc (receiveMessage): Do not create message 
class
	here.
	(receiveHandshake): Do not create handshake class here.
	* src/PeerInteractionCommand.h (peerConnection): Removed.
	(piece): Removed.
	(syncPiece): Removed.
	(sendInterest): Removed.
	(sendMessages): Removed.
	(createRequestPendingMessage): Removed.
	(checkPieceHash): Removed.
	(erasePieceOnDisk): Removed.
	(getNewPieceAndSendInterest): Removed.
	(onGotNewPice): Removed.
	(onGotWrongPiece): Removed.
	* src/PeerInteractionCommand.cc (PeerInteractionCommand):
	Removed peerConnection, piece.
	(~PeerInteractionCommand): Removed peerConnection.
	(executeInternal): Use sendMessageQueue instead of 
peerConnection.
	(syncPiece): Moved to SendMessageQueue.
	(decideChoking): Removed PendingMessage.
	(receiveMessage): Use sendMessageQueue instead of 
peerConnection.
	The action after receiving peer message was moved to each 
message
	class.
	(onGotNewPice): Moved to SendMessageQueue.
	(onGotWrongPiece): Moved to SendMessageQueue.
	(getNewPieceAndSendInterest): Moved to SendMessageQueue.
	(sendInterest): Moved to SendMessageQueue.
	(createRequestPendingMessage): Removed.
	(sendMessages): Moved to SendMessageQueue.
	(onAbort): Use SendMessageQueue::abortPiece()
	(keepAlive): Use sendMessageQueue instead of peerConnection.
	(beforeSocketCheck): Use sendMessageQueue instead of 
peerConnection.
	(checkPieceHash): Moved to SendMessageQueue.
	(erasePieceOnDisk): Moved to SendMessageQueue.
	* src/PeerMessageUtil.h
	(createBitfieldMessage): Removed.
	(createHaveMessage): Changed return value and arguments.
	(createBitfieldMessage): Changed return value and arguments.
	(createRequestCancelMessage): Removed.
	(createPieceMessage): Changed return value and arguments.
	(getShortIntParam): New function.
	(checkIndex): Changed arguments.
	(checkBegin): Changed arguments.
	(checkLength): Changed arguments.
	(checkPieceOffset): Removed.
	(checkRange): New function.
	(checkBitfield): Changed arguments.
	(createPeerMessage): Removed.
	(checkIntegrity): Removed.
	(createHandshakeMessage): Changed arguments.
	(createChokeMessage): New function.
	(createUnchokeMessage): New function.
	(createInterestedMessage): New function.
	(createNotInterestedMessage): New function.
	(createRequestMessage): New function.
	(createCancelMessage): New function.
	(createPortMessage): New function.
	* src/PeerMessageUtil.cc
	(createBitfieldMessage): Removed.
	(createHaveMessage): Changed return value and arguments.
	(createBitfieldMessage): Changed return value and arguments.
	(createRequestCancelMessage): Removed.
	(createPieceMessage): Changed return value and arguments.
	(getShortIntParam): New function.
	(checkIndex): Changed arguments.
	(checkBegin): Changed arguments.
	(checkLength): Changed arguments.
	(checkPieceOffset): Removed.
	(checkRange): New function.
	(checkBitfield): Changed arguments.
	(createPeerMessage): Removed.
	(checkIntegrity): Removed.
	(createHandshakeMessage): Changed arguments.
	(createChokeMessage): New function.
	(createUnchokeMessage): New function.
	(createInterestedMessage): New function.
	(createNotInterestedMessage): New function.
	(createRequestMessage): New function.
	(createCancelMessage): New function.
	(createPortMessage): New function.
	* src/PeerMessage.h
	(id): Removed.
	(index): Removed.
	(begin): Removed.
	(length): Removed.
	(bitfield): Removed.
	(bitfieldLength): Removed.
	(block): Removed.
	(blockLength): Removed.
	(inProgress): New variable.
	(cuid): New variable.
	(peer): New variable.
	(sendMessageQueue): New variable.
	(logger): New variable.
	(setBitfield): Removed.
	(getBitfield): Removed.
	(setBlock): Removed.
	(getBlock): Removed.
	(getBitfieldLength): Removed.
	(getBlockLength): Removed.
	(isInProgress): New function.
	(toString): Made pure virtual.
	(check): New function.
	(send): New function.
	(receivedAction): New function.
	(getId): Made pure virtual.
	(setId): Removed.
	(getIndex): Removed.
	(setIndex): Removed.
	(getBegin): Removed.
	(setBegin): Removed.
	(getLength): Removed.
	(setLength): Removed.
	(getCuid): New function.
	(setCuid): New function.
	(getPeer): New function.
	(setPeer): New function.
	(getSendMessageQueue): New function.
	(setSendMessageQueue): New function.
	(ID): Removed.
	* src/PeerMessage.cc
	(setBitfield): Removed.
	(setBlock): Removed.
	(toString): Removed.
	* src/TorrentMan.h
	(getPieceLength): New function.
	(getPieceLength): New function.
	* src/SendMessageQueue.h
	(REQUEST_TIME_OUT): New definition.
	(RequestSlots): New definition.
	(MessageQueue): New definition.
	(requestSlotMan): Removed.
	(pendingMessages): Removed.
	(requestSlots): New variable.
	(messageQueue): New variable.
	(torrentMan): New variable.
	(peerConnection): New variable.
	(peer): New variable.
	(piece): New variable.
	(getNewPieceAndSendInterest): New function.
	(createPeerMessage): New function.
	(createHandshakeMessage): New function.
	(send): Made private.
	(setPeerMessageCommonProperty): New function.
	(deleteAllRequestSlot): New function.
	(deleteRequestMessageInQueue): New function.
	(cancelAllRequest): Made private.
	(cancelAllRequest): Made private.
	(countRequestSlot): Made private.
	(addPendingMessage): Removed.
	(deletePendingPieceMessage): Removed.
	(deletePendingRequestMessage): Removed.
	(addMessage): New function.
	(deletePieceMessageInQueue): New function.
	(deleteTimeoutRequestSlot): Changed argument.
	(deleteCompletedRequestSlot): Changed argument.
	(getCorrespoindingRequestSlot): Renamed to 
getCorrespondingRequestSlot.
	(getCorrespondingRequestSlot): New function.
	(countPendingMessage): Removed.
	(countMessageInQueue): New function.
	(getTorrentMan): New function.
	(getPeerConnection): New function.
	(hasDownloadPiece): New function.
	(getDownloadPiece): New function.
	(setDownloadPiece): New function.
	(syncPiece): New function.
	(sendMessages): New function.
	(sendNow): New function.
	(trySendNow): New function.
	(abortPiece): New function.
	(sendHandshake): New function.
	(receiveMessage): New function.
	(receiveHandshake): New function.
	(createRequestMessage): New function.
	(createCancelMessage): New function.
	(createPieceMessage): New function.
	(createHaveMessage): New function.
	(createChokeMessage): New function.
	(createUnchokeMessage): New function.
	(createInterestedMessage): New function.
	(createNotInterestedMessage): New function.
	(createBitfieldMessage): New function.
	(createKeepAliveMessage): New function.
	* src/SendMessageQueue.cc
	(SendMessageQueue): Removed requestSlotMan.
	Instantiated peerConnection here.
	(~SendMessageQueue): Removed requestSlotMan.
	Added deletion of peerConnection and the contents of 
messageQueue.
	(send): Updated according to the change of messageQueue.
	(addPendingMessage): Renamed to addMessage.
	(addMessage): New function.
	(deletePendingPieceMessage): Renamed to 
deletePieceMessageInQueue.
	(deletePieceMessageInQueue): New function.
	(deletePendingRequestMessage): Renamed to 
deleteRequestMessageInQueue.
	(deleteRequestMessageInQueue): New function.
	(deleteRequestSlot): RequestSlotMan::deleteRequestSlot(...) was 
moved
	here.
	(deleteTimeoutRequestSlot): 
RequestSlotMan::deleteTimeoutRequestSlot
	(...) was moved here.
	(deleteAllRequestSlot): 
RequestSlotMan::deleteAllRequestSlot(...) was
	moved here.
	(deleteCompletedRequestSlot):
	RequestSlotMan::deleteCompletedRequestSlot(...) was moved here.
	(getCorrespondingRequestSlot):
	RequestSlotMan::getCorrespoindingRequestSlot(...) was moved 
here.
	And renamed to getCorrespondingRequestSlot, correcting a typo.
	(countPendingMessage): Renamed to countMessageInQueue.
	(countMessageInQueue): New function.
	(countRequestSlot): RequestSlotMan::countRequestSlot() was moved 
here.
	(receiveHandshake): New function.
	(createHandshakeMessage): New function.
	(receiveMessage): New function.
	(createPeerMessage): New function.
	(syncPiece): New function.
	(getNewPieceAndSendInterest): New function.
	(sendMessages): New function.
	(sendNow): New function.
	(trySendNow): New function.
	(sendHandshake): New function.
	(abortPiece): New function.
	(getDownloadPiece): New function.
	(getPeerMessageCommonProperty): New function.
	(createRequestMessage): New function.
	(createCancelMessage): New function.
	(createPieceMessage): New function.
	(createHaveMessage): New function.
	(createChokeMessage): New function.
	(createUnchokeMessage): New function.
	(createInterestedMessage): New function.
	(createNotInterestedMessage): New function.
	(createBitfieldMessage): New function.
	(createKeepAliveMessage): New function.
	
	
	To add simple Content-Disposition support:

	* src/HttpResponseCommand.h (determinFilename): New function.
	* src/HttpResponseCommand.cc (executeInternal):
	Use determinFilename(headers) instead of req->getFile() when 
comparing
	filename.
	(determinFilename): New function.
	(handleDefaultEncoding): Use determinFilename(headers) instead 
of
	req->getFile().
	(handleOtherEncoding): Use determinFilename(headers) instead of
	req->getFile().
	* src/Util.h (getContentDispositionFilename): New function.
	* src/Util.cc (getContentDispositionFilename): New function.
	
	* src/LogFactory.h (release): New function.
	* src/LogFactory.cc (release): New function.

	To fix a bug that causes out-of-bound exception when HTTP status
	line is wrong:
	
	* src/HttpConnection.cc (receiveResponse): Added a check for 
header
	size.

	* src/common.h (Deleter): New class.

	* src/SegmentMan.cc
	(~SegmentMan): Added deletion of splitter and diskWriter.
	* src/DownloadEngine.h
	(Commands): Use deque.
	(clearQueue): New function.
	* src/DownloadEngine.cc
	(~DownloadEngine): Added deletion of segmentMan.
	(cleanQueue): New function.
	* src/TorrentDownloadEngine.h
	(TorrentDownloadEngine): The implementation was moved to
	TorrentDownloadEngine.cc.
	(~TorrentDownloadEngine): The implementation was moved to
	TorrentDownloadEngine.cc.
	* src/TorrentDownloadEngine.cc
	(~TorrentDownloadEngine): Added deletion of torrentMan.
	* src/main.cc
	(clearRequest): Removed.
	(handler): Added deletion of e.
	(torrentHandler): Added deletion of te.
	(main): Do not share splitter.
	Use Deleter instead of clearRequest.
	Deletion of classes were updated.
2006-05-09 15:54:14 +00:00
Tatsuhiro Tsujikawa
500e978628 * src/main.cc (main): Fixed typo.
* src/message.h: Fixed typo.

	* po/de.po: Added German translation, thanks to Hermann J. 
Beckers.
2006-05-06 01:08:42 +00:00
Tatsuhiro Tsujikawa
75deb4e605 2006-04-29 17:41:49 +00:00
Tatsuhiro Tsujikawa
d6100c7507 2006-04-29 16:18:00 +00:00
Tatsuhiro Tsujikawa
da7edb7867 2006-04-29 11:23:53 +00:00
Tatsuhiro Tsujikawa
15b207a53e * src/SocketCore.cc
(writeData): Removed timeout argument.
	(readData): Removed timeout argument.
	(peekData): Removed timeout argument.
	* src/Socket.cc
	(writeData): Removed timeout argument.
	(readData): Removed timeout argument.
	(peekData): Removed timeout argument.
2006-04-29 11:23:39 +00:00
Tatsuhiro Tsujikawa
df2364b1db 2006-04-29 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add --select-file command-line option:
	
	* src/Util.cc
	(unfoldRange): New function.
	(getNum): New function.
	(unfoldSubRange): New function
	* src/main.cc
	(showUsage): Added help message.
	(main): Added --select-file command-line option.
	
2006-04-28  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	To deploy upload rate based choking algorithm:
	
	* src/PeerInteractionCommand.cc
	(PeerInteractionCommand): Add peer to TorrentMan::activePeers to 
track
	peer currently used.
	(decideChoking): Deleted the choke/unchoke decision algorithm 
when
	download completes. Simplified.
	(receiveMessage): Updated.
	* src/TorrentMan.h
	(activePeers): New variable.
	(addActivePeer): New function.
	(getActivePeers): New function.
	(deleteActivePeer): New function.
	* src/TorrentMan.cc
	(addPeer): deleteOldErrorPeers is moved to the begining of the 
function
	* src/PeerAbstractCommand.cc
	(onAbort): Use peer->resetStatus().
	* src/main.cc
	(PeerChokeCommand.h): Included.
	(main): Added the instance of ChokingCommand to the command 
queue.
	* src/Peer.h
	(amChoking): Renamed from amChocking
	(chokingRequired): New variable.
	(optUnchoking): New variable.
	(deltaUpload): New variable.
	(deltaDownload): New variable.
	(addDeltaUpload): New function.
	(resetDeltaUpload): New function.
	(addDeltaDownload): New function.
	(resetDeltaDownload): New function.
	(addPeerUpload): Added a call to addDeltaUpload.
	(addPeerDownload): Added a call to addDeltaDownload.
	* src/Peer.cc
	(shouldBeChoking): Renamed from shouldChoke.
	(resetStatus): New function.
	* src/PeerChokeCommand.h: New class.
	* src/PeerChokeCommand.cc: New class.
	
	To add lazy upload speed limiter:

	* src/TorrentConsoleDownloadEngine.h: Moved the variables for
	statistics calculation to TorrentDownloadEngine.
	* src/TorrentConsoleDownloadEngine.cc
	(sendStatistics): Renamed from printStatistics.
	(initStatistics): Removed. Moved to TorrentDownloadEngine.
	(calculateSpeed): Removed. Moved to TorrentDownloadEngine.
	(calculateStatistics): Removed. Moved to TorrentDownloadEngine.
	* src/TorrentDownloadEngine.h: Added the variables for 
statistics
	calculation.
	(sendStatistics): New function as pure virtual function.
	(getUploadSpeed): New function.
	* src/TorrentDownloadEngine.cc
	(initStatistics): New function.
	(calculateSpeed): New function.
	(calculateStatistics): New function.
	* src/SendMessageQueue.h
	(uploadLength): New variable.
	(send): Added an argument.
	(setUploadLimit): New function.
	(getUploadLimit): New function.
	* src/SendMessageQueue.cc
	(send): Added upload speed limiter.
	* src/prefs.h
	(PREF_UPLOAD_LIMIT): New definition.
	* src/PeerInteractionCommand.cc
	(PeerInteractionCommand): Set upload speed limit to 
sendMessageQueue.
	* src/main.cc
	(main): Added --upload-limit option

	For bug fixes:
	
	* src/main.cc
	(showUsage): Corrected --listen-port help

	Other changes:
	
	* src/TorrentMan.cc
	(getPeer): Return nullPeer if connection is grather than
	MAX_PEER_UPDATE(15) in order to leave space for incoming peers.
2006-04-28 15:55:11 +00:00
Tatsuhiro Tsujikawa
af2a03fbf1 2006-04-21 13:18:42 +00:00