Commit Graph

4818 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa
2fb9b5be97 2006-09-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To rewrite segment download mechanism for HTTP/FTP download.
	Use BitfieldMan to manage segment download.
	* src/HttpResponseCommand.h
	(executeInternal): Pass the reference of segment.
	* src/AbstractCommand.cc
	(prepareForRetry): Call segmentMan->cancelSegment here.
	(onAbort): Call segmentMan->cancelSegment here.
	* src/HttpDownloadCommand.cc
	(prepareForNextSegment): New function.
	* src/DownloadEngineFactory.cc
	(newConsoleEngine): Removed splitter.
	(newTorrentConsoleEngine): Removed splitter.
	* src/Request.h
	(segment): Renamed from seg.
	* src/FtpInitiateConnectionCommand.h
	(executeInternal): Pass the reference of segment.
	* src/AbstractCommand.h
	(executeInternal): Pass the reference of segment.
	* src/pref.h
	(PREF_SEGMENT_SIZE): New definition.
	* src/HttpProxyRequestCommand.h
	(executeInternal): Pass the reference of segment.
	* src/HttpResponseCommand.cc
	(checkResponse): Allowed status 206 when a request range starts 
0.
	(handleDefaultEncoding): Rewritten the code related to Segment.
	(handleOtherEncoding): Rewritten the code related to Segment.
	* src/SegmentMan.h
	(SegmentEntry): New class.
	(SegmentEntries): New type definition.
	(bitfield): New variable.
	(usedSegmentEntries): New variable.
	(onNullBitfield): New function.
	(checkoutSegment): New function.
	(segments): Removed.
	(splitter): Removed.
	(unregisterId): Removed.
	(getSegment): New function(overload)
	(getDownloadedSize): Removed.
	(cancelSegment): New function.
	(completeSegment): New function.
	(initBitfield): New function.
	(hasSegment): New function.
	(getDownloadLength): New function.
	* src/BitfieldMan.h
	(getStartIndex): New function.
	(getEndIndex): New function.
	(getMissingUnusedIndex): New function(overload).
	(getSparseMissingUnusedIndex): New function.	
	* src/BitfieldMan.cc
	(getMissingIndexRandomly): Handle the last byte of bitfield 
properly.
	(getMissingUnusedIndex): New function(overload).
	(Range): New class.
	(getStartIndex): New function.
	(getEndIndex): New function.
	(getSparseMissingUnusedIndex): New function.
	(isBitSetInternal): Return false if the given index is less than 
0.
	* src/HttpInitiateConnectionCommand.h
	(executeInternal): Pass the reference of segment.
	* src/FtpNegotiateCommand.h
	(executeInternal): Pass the reference of segment.
	* src/FtpNegotiateCommand.cc
	(recvSize): Initialize bitfield here.
	* src/FtpTunnelResponseCommand.h
	(executeInternal): Pass the reference of segment.
	* src/HttpConnection.cc
	(createRequest): Rewritten range header processing.
	* src/DownloadCommand.h
	(executeInternal): Pass the reference of segment.
	(prepareForRetry): Removed.
	(prepareForNextSegment): Added an argument segment. Made it a 
virtual
	function.
	* src/main.cc
	(main): Set the initial value of PREF_SEGMENT_SIZE to 1MB.
	* src/SegmentMan.cc
	(SegmentMan): Added bitfield. Removed splitter.
	(~SegmentMan): Added bitfield. Removed splitter.
	(unregisterId): Removed.
	(getSegment): Rewritten.
	(updateSegment): Rewritten.
	(save): Rewritten.
	(read): Rewritten.
	(finished): Rewritten.
	(getDownloadedSize): Removed.
	(initBitfield): New function.
	(FindSegmentEntryByIndex): New function object.
	(FindSegmentEntryByCuid): New function object.
	(checkoutSegment): New function.
	(onNullBitfield): New function.
	(getSegment): New function(overload).
	(CancelSegment): New function object.
	(cancelSegment): New function.
	(completeSegment): New function.
	(hasSegment): New function.
	(getDownloadLength): New function.
	* src/FtpInitiateConnectionCommand.cc
	(executeInternal): Load .aria2 file after hostname resolution 
finishes.
	* src/Segment.h: Rewritten.
	* src/Segment.cc (operator<<): New function.
	* src/HttpDownloadCommand.h
	(prepareForNextSegment): New function.
	* src/Request.cc
	(resetUrl): Made segment null.
	* src/DownloadEngine.cc
	(~DownloadEngine): Call cleanQueue before deleting segmentMan.
	* src/HttpProxyRequestCommand.h
	(executeInternal): Pass the reference of segment.
	* src/DownloadCommand.cc
	(executeInternal): Rewritten the code related to Segment.
	(prepareForRetry): Removed.
	(prepareForNextSegment): Rewritten.
	* src/FtpTunnelResponseCommand.h
	(executeInternal): Pass the reference of segment.
	
	To add HTTP 1.1 persistent connection support(experimental)
	* src/HttpRequestCommand.cc
	(executeInternal): Disable keep alive if it is disabled by
	configuration.
	* src/Request.h
	(keepAlive): New variable.
	(isKeepAlive): New function.
	(setKeepAlive): New function.
	* src/pref.h
	(PREF_HTTP_KEEP_ALIVE): New definition.
	* src/HttpResponseCommand.cc
	(executeInternal): Check the remote server supports keep alive.
	* src/HttpConnection.cc
	(createRequest): Send "Connection: close" only if keep alive is
	disabled.
	* src/main.cc
	(main):
	Set the initial value(false) of PREF_KEEP_ALIVE to false.

	To add max download speed limit:
	* src/pref.h
	(PREF_MAX_SPEED_LIMIT): New definition.
	* src/PeerInteractionCommand.cc
	(executeInternal): Added max download speed limit. Not tested 
yet.
	* src/SegmentMan.h
	(PeerStats): New type definition.
	(peerStats): New variable.
	(registerPeerStat): New function.
	(FindPeerStat): New function object.
	(getPeerStat): New function.
	(calculateDownloadSpeed): New function.
	* src/SpeedCalc.h: New class.
	* src/SpeedCalc.cc: New class.
	* src/main.cc
	(main):
	Set the initial value of PREF_MAX_SPEED_LIMIT to 0(which means 
the
	download speed is not restricted).
	* src/PeerStat.h: New class.
	* src/SegmentMan.cc
	(registerPeerStat): New function.
	(calculateDownloadSpeed): New function.
	* src/DownloadCommand.cc
	(STARTUP_IDLE_TIME): New definition.
	(DownloadCommand): Register peerStat to segmentMan. Call 
peerStat->
	downloadStart.
	(~DownloadCommand): Call peerStat->downloadStop.
	(executeInternal): Added download speed limitter. Rewritten 
lowest
	speed limitter.

	* src/HttpConnection.cc
	(receiveResponse): Fixed: eohIndex[headerBuf] -> 
headerBuf[eohIndex].
	
	* src/AbstractCommand.cc
	(resolveHostname): Throw DlAbortEx if a name resolution failes.
	Added hostname to the error message.
	
	* src/ConsoleDownloadEngine.cc
	(calculateStatistics): Initialize psize with dlSize.

	* src/PieceMessage.cc
	(receivedAction): Do not call peerInteraction->abortPiece here.
	(onGotWrongPiece): Call peerInteraction->abortPiece here.

	* src/BitfieldMan.h
	(clearAllUseBit): New function.
	(setAllUseBit): New function.
	* src/BitfieldMan.cc
	(clearAllBit): Do not clear useBitfield here.
	(clearAllUseBit): New function.
	(setAllUseBit): New function.
	* src/Piece.cc
	(clearAllBlock): Call bitfield->clearAllUseBit().
2006-09-19 14:52:59 +00:00
Tatsuhiro Tsujikawa
1d52ba244e 2006-08-28 15:40:50 +00:00
Tatsuhiro Tsujikawa
d63e6fb052 To fix a bug that caused assertion failure in ares_strerror:
* src/NameResolver.cc (callback): Fixed the bug.
2006-08-28 13:30:24 +00:00
Tatsuhiro Tsujikawa
c096a3a553 2006-08-28 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To make filename URL-decoded:
	* src/HttpResponseCommand.h: Updated doc.
	* src/HttpResponseCommand.cc
	(determinFilename): Made filename URL-decoded.
	* src/FtpInitiateConnectionCommand.cc
	(executeInternal): Made filename URL-decoded.
	* src/Util.h (urldecode): New function.
	* src/Util.cc (urldecode): New function.
2006-08-28 12:40:41 +00:00
Tatsuhiro Tsujikawa
531d456950 2006-08-27 12:51:12 +00:00
Tatsuhiro Tsujikawa
3b2a98393e 2006-08-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add --seed-time and --seed-ratio command-line option:
	* src/Option.h (getAsDouble): New function.
	* src/Option.cc (getAsDouble): New function.
	* src/SeedCheckCommand.h: New class.
	* src/SeedCheckCommand.cc: New class.
	* src/DownloadEngineFactory.cc
	(SeedCheckCommand.h): Included.
	(UnionSeedCriteria.h): Included.
	(TimeSeedCriteria.h): Included.
	(ShareRatioSeedCriteria.h): Included.
	(newTorrentConsoleEngine): Added the processing of seed option.
	* src/SeedCriteria.h: New class.
	* src/ShareRatioSeedCriteria.h: New class.
	* src/TimeSeedCriteria.h: New class.
	* src/UnionSeedCriteria.h: New class.
	* src/prefs.h
	(PREF_SEED_TIME): New definition.
	(PREF_SEED_RATIO): New definition.
	* src/main.cc
	(showUsage): Added --seed-time and --seed-ratio option.
	(main): Added --seed-time and --seed-ratio option.
	Made default log file name "/dev/null".
	* src/SharedHandle.h
	(SharedHandle): Copy constructor. Made it assignable from the
	SharedHandle of the subclasses.
	(operator=): Made it assignable from the SharedHandle of the
	subclasses.
	(getRefCount): New function.
	
	To add notice log level and the switch to write log to stdout. 
This
	switch is configurable per log level.
	* src/Logger.h
	(notice): New function.
	(LEVEL): Added NOTICE. Assigned an explicit value to each log 
level
	constant.
	* src/LogFactory.cc
	(getInstance): The use of NullLogger was removed. A log message 
with
	notice log level was made written to stdout along with log file.
	* src/NullLogger.h
	(notice): New function.
	* src/SimpleLogger.h
	(writeHeader): Added the 'file' argument.
	(writeLog): Added the 'file' argument.
	(writeFile): New function.
	(stdoutField): New variable.
	(SimpleLogger): Removed the default constructor.
	(SimpleLogger): Made the default value of logfile 0.
	(debug): Added 'virtual' keyword.
	(info): Added 'virtual' keyword.
	(warn): Added 'virtual' keyword.
	(error): Added 'virtual' keyword.
	(notice): New function.
	(setStdout): New function.
	* src/SimpleLogger.cc
	(WRITE_LOG): Replaced writeLog with writeFile.
	(WRITE_LOG_EX): Replaced writeLog with writeFile.
	(SimpleLogger): Removed the default constructor.
	(setStdout): New function.
	(writeLog): Added the handling of NOTICE log level.
	(writeFile): New function.
	(notice): New function.

	* src/TorrentMan.h: Updated doc.

	* src/BitfieldMan.h: Updated doc.
	
	* src/TrackerWatcherCommand.cc
	(execute): Return true if error occurred in the request to the 
tracker
	and halt is requested.

	* src/TrackerUpdateCommand.cc
	(execute): Return true if error occurred in the request to the 
tracker
	and halt is requested.

	* src/TorrentConsoleDownloadEngine.h
	(onSelectiveDownloadingCompletes): Removed.
	* src/TorrentConsoleDownloadEngine.cc
	(onSelectiveDownloadingCompletes): Removed.
	* src/TorrentDownloadEngine.h
	(onEndOfRun): Added 'virtual' keyword.
	(afterEachIteration): Removed.
	(onSelectiveDownloadingCompletes): Removed.
	* src/TorrentDownloadEngine.cc
	(onEndOfRun): Removed filenameFixed.
	(afterEachIteration): Removed.	
	* src/TorrentMan.cc
	(completePiece): Call onDownloadComplete here.
	(onDownloadComplete): Added 2 log messages.
2006-08-27 12:49:17 +00:00
Tatsuhiro Tsujikawa
e9f907fe1e 2006-08-21 15:04:49 +00:00
Tatsuhiro Tsujikawa
b4237e5752 2006-08-21 14:36:20 +00:00
Tatsuhiro Tsujikawa
e13e16f559 2006-08-21 14:35:22 +00:00
Tatsuhiro Tsujikawa
f45ad3b5d9 This is release 0.7.2 2006-08-21 14:34:42 +00:00
Tatsuhiro Tsujikawa
0c4ade346c 2006-08-21 14:31:18 +00:00
Tatsuhiro Tsujikawa
35f5dbb642 Fixed src/Makefile.am 2006-08-21 14:29:14 +00:00
Tatsuhiro Tsujikawa
23c323c1fc Added @LIBCARES_LIBS@ and @LIBCARES_CPPFLAGS@ in src/Makefile.am 2006-08-21 14:26:15 +00:00
Tatsuhiro Tsujikawa
c3f7478a6e 2006-08-21 14:01:59 +00:00
Tatsuhiro Tsujikawa
ded48c43f2 Added m4/libcares.m4 2006-08-21 13:54:15 +00:00
Tatsuhiro Tsujikawa
fda031576c 2006-08-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To fix the bug that causes compilation failure with 
metalink-support
	disabled(bug#1543587):

	* src/main.cc: Fixed with the patch by tizianomueller.
2006-08-21 13:31:49 +00:00
Tatsuhiro Tsujikawa
4def45feb2 2006-08-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To fix compilation problem on gcc4.1.1(patch#1542283 by 
tizianomueller)
	* src/NameResolver.h: Added the prototype declaration of 
callback().
	
	To support c-ares library:
	
	* src/AbstractCommand.cc: Replaced HAVE_LIBARES with 
ENABLE_ASYNC_DNS
	* src/FeatureConfig.cc: Replaced HAVE_LIBARES with 
ENABLE_ASYNC_DNS
	* src/FtpInitiateConnectionCommand.h:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/AbstractCommand.h: Replaced HAVE_LIBARES with 
ENABLE_ASYNC_DNS
	* src/HttpInitiateConnectionCommand.h:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/NameResolver.cc: Replaced HAVE_LIBARES with 
ENABLE_ASYNC_DNS
	* src/HttpInitiateConnectionCommand.cc:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/FtpInitiateConnectionCommand.cc:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/DownloadEngine.h:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
	* src/DownloadEngine.cc:
	Replaced HAVE_LIBARES with ENABLE_ASYNC_DNS
2006-08-21 13:18:51 +00:00
Tatsuhiro Tsujikawa
29d1723996 2006-08-14 15:19:11 +00:00
Tatsuhiro Tsujikawa
11dc664f83 2006-08-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/FeatureConfig.cc
	(FEATURE_ASYNC_DNS): New definition.
	(FeatureConfig): Added aysnc DNS entry.

	To replace CommandUuid with Command* in SocketEntry and
	NameResolverEntry:
	
	* src/DownloadEngine.h
	(CommandUuids): Removed.
	(SocketEntry::commandUuid): Removed.
	(SocketEntry::command): New variable.
	(SocketEntry::SocketEntry): Updated.
	(SocketEntry::operator==): Updated.
	(NameResolverEntry::commandUuid): Removed.
	(NameResolverEntry::command): New variable.
	(NameResolverEntry::NameResolverEntry): Updated.
	(NameResolverEntry::operator==): Updated.
	(waitData): Changed the argument type.
	(addSocketForReadCheck): Changed the argument type.
	(deleteSocketForReadCheck): Changed the argument type.
	(addSocketForWriteCheck): Changed the argument type.
	(deleteSocketForWriteCheck): Changed the argument type.
	(addNameResolverCheck): Changed the argument type.
	(deleteNameResolverCheck): Changed the argument type.
	* src/DownloadEngine.cc
	(FindCommand): Removed.
	(run): Removed activeUuid. Added activeCommands instead.
	(AccumulateActiveUuid): Renamed as AccumulateActiveCommand.
	(AccumulateActiveCommand): New function object.
	(waitData): Use AccumulateActiveCommand.
	(addSocketForReadCheck): Use Command instead of CommandUuid.
	(deleteSocketForReadCheck): Use Command instead of CommandUuid.
	(addSocketForWriteCheck): Use Command instead of CommandUuid.
	(deleteSocketForWriteCheck): Use Command instead of CommandUuid.
	(addNameResolverCheck): Use Command instead of CommandUuid.
	(deleteNameResolverCheck): Use Command instead of CommandUuid.	
	* src/AbstractCommand.cc
	(disableReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(disableWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setNameResolverCheck): Updated according to the changes in
	DownloadEngine.
	(disableNameResolverCheck): Updated according to the changes in
	DownloadEngine.
	* src/AbstractCommand.cc
	(disableReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setReadCheckSocket): Updated according to the changes in
	DownloadEngine.
	(disableWriteCheckSocket): Updated according to the changes in
	DownloadEngine.
	(setWriteCheckSocket): Updated according to the changes in
	DownloadEngine.

	* release 0.7.1
2006-08-14 15:03:38 +00:00
Tatsuhiro Tsujikawa
e3b0153e85 2006-08-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/main.cc
	(main): Added a message to inform users that aria2 is starting 
to
	verify checksum.
	* src/RequestInfo.cc
	(printDownloadAbortMessage): Added a message to inform users 
that
	transfer can be resumed.

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

	To handle the case where some BitTorrent tracker requires all 
letters
	except for [A-Za-z0-9] is URL encoded.
	
	* src/Util.h
	(torrentUrlencode): New function.
	* src/Util.cc
	(ctype.h): Included.
	(torrentUrlencode): New function.
	* src/TrackerWatcherCommand.cc
	(execute): Use Util::torrentUrlencode() instead of 
Util::urlencode().
2006-08-14 11:38:28 +00:00
Tatsuhiro Tsujikawa
f2d4faad08 2006-08-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add asynchronous DNS support(libares):

	* src/AbstractCommand.h
	(setNameResolverCheck): New function.
	(disableNameResolverCheck): New function
	(resolveHostname): New function.
	* src/AbstractCommand.cc
	(setNameResolverCheck): New function.
	(disableNameResolverCheck): New function
	(resolveHostname): New function.
	* src/FtpInitiateConnectionCommand.h
	(nameResolver): New function.
	* src/FtpInitiateConnectionCommand.cc
	(Util.h): Included.
	(FtpInitiateConnectionCommand): Call disableReadCheckSocket,
	disableWriteCheckSocket.
	(~FtpInitiateConnectionCommand): Call disableNameResolverCheck.
	(executeInternal): Added async DNS support.
	* src/HttpInitiateConnectionCommand.h
	(nameResolver): New function.
	* src/HttpInitiateConnectionCommand.cc
	(DlRetryEx.h): Included.
	(HttpInitiateConnectionCommand): Call disableReadCheckSocket,
	disableWriteCheckSocket.
	(~HttpInitiateConnectionCommand): Call disableNameResolverCheck.
	(executeInternal): Added async DNS support.
	* src/NameResolver.h: New class. Note: #include <ares.h> is 
surrounded
	by extern "C" declaration.
	* src/NameResolver.cc: New class.
	* src/Util.h:
	(isNumberAndDotsNotation): New function
	* src/Util.cc
	(isNumberAndDotsNotation): New function.
	* src/DownloadEngine.h
	(NameResolver.h): Included.
	(NameResolverEntry): New class.
	(NameResolverEntries): New type definition.
	(addNameResolverCheck): New function.
	(deleteNameResolverCheck): New function.
	* src/DownloadEngine.cc
	(run): Initialize cp with 0.
	(SetDescriptor::operator()): Added for NameResolverEntry.
	(AccumulateActiveUuid::operator()): Added for NameResolverEntry.
	(waitData): Check nameResolver entries.
	(updateFdSet): Update fds in nameResolver entries.
	(addNameResolverCheck): New function.
	(deleteNameResolverCheck): new function.
	
	* src/PeerInteractionCommand.cc
	(executeInternal): Fixed wrong socket handling.

	* src/main.cc
	(main): Fixed the initial value of PREF_LOWEST_SPEED_LIMIT 
option to 0.

	* src/Util.cc
	(fileChecksum): Removed the call to ctx.digestReset().
2006-08-11 12:29:55 +00:00
Tatsuhiro Tsujikawa
7ca1b43edd 2006-08-08 14:09:13 +00:00
Tatsuhiro Tsujikawa
19a21795e0 * src/FtpNegotiateCommand.cc
(recvGreeting): Call disableWriteCheckSocket just after
	socket->setBlockingMode(). This avoids unnecessary CPU-hog loop.
	(recvRetr): Recognized status code 125 as a acceptable response 
code.
2006-08-07 17:21:09 +00:00
Tatsuhiro Tsujikawa
d0068e5a9c Added src/Command.cc 2006-08-07 16:57:14 +00:00
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