mirror of https://github.com/aria2/aria2
				
				
				
			
			
			
			
				pull/1/head
			
			
		
		
							parent
							
								
									27d392d5f2
								
							
						
					
					
						commit
						2462a3b06c
					
				| 
						 | 
					@ -1,5 +1,14 @@
 | 
				
			||||||
2006-02-22  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
					2006-02-22  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* SplitSlowestSegmentSplitter.{h,cc}: This class provies algorithm
 | 
				
			||||||
 | 
						that splits slowest segment of SegmentMan::commands vector.
 | 
				
			||||||
 | 
						This is the default split algorithm of aria2.
 | 
				
			||||||
 | 
						* SplitFirstSegmentSplitter.{h,cc}: This class provides algorithm
 | 
				
			||||||
 | 
						that splits first segment of SegmentMan::commands vector.
 | 
				
			||||||
 | 
						* SegmentSplitter.{h,cc}: Added. This class provides split algorithm.
 | 
				
			||||||
 | 
						* DownloadCommand.{h,cc}: Added downloading speed calculation.
 | 
				
			||||||
 | 
						* Segment.h:
 | 
				
			||||||
 | 
						* SegmentMan.cc: Added speed field to Segment.h
 | 
				
			||||||
	* main.cc: -s option now affects all URLs in command-line arguemtns.
 | 
						* main.cc: -s option now affects all URLs in command-line arguemtns.
 | 
				
			||||||
	* HttpResponseCommand.cc: Fixed bug that segment file is not loaded.
 | 
						* HttpResponseCommand.cc: Fixed bug that segment file is not loaded.
 | 
				
			||||||
	* message.h: Change file size related %d to %lld.
 | 
						* message.h: Change file size related %d to %lld.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										3
									
								
								TODO
								
								
								
								
							
							
						
						
									
										3
									
								
								TODO
								
								
								
								
							| 
						 | 
					@ -5,5 +5,4 @@
 | 
				
			||||||
* Better HTTP status handling
 | 
					* Better HTTP status handling
 | 
				
			||||||
* Download files listed in a specifed file.
 | 
					* Download files listed in a specifed file.
 | 
				
			||||||
* check MD5 checksum
 | 
					* check MD5 checksum
 | 
				
			||||||
* Apply "split longest remianing time first" algorithm to SegmentMan.
 | 
					* Add the feature which adds or removes URLs on-the-fly.
 | 
				
			||||||
* split algorithm must be separate class.
 | 
					 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,10 @@
 | 
				
			||||||
#include "InitiateConnectionCommandFactory.h"
 | 
					#include "InitiateConnectionCommandFactory.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DownloadCommand::DownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):AbstractCommand(cuid, req, e, s) {}
 | 
					DownloadCommand::DownloadCommand(int cuid, Request* req, DownloadEngine* e, Socket* s):AbstractCommand(cuid, req, e, s), lastSize(0) {
 | 
				
			||||||
 | 
					  sw.tv_sec = 0;
 | 
				
			||||||
 | 
					  sw.tv_usec = 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DownloadCommand::~DownloadCommand() {}
 | 
					DownloadCommand::~DownloadCommand() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,6 +53,20 @@ bool DownloadCommand::executeInternal(Segment seg) {
 | 
				
			||||||
    e->diskWriter->writeData(buf, bufSize, seg.sp+seg.ds);
 | 
					    e->diskWriter->writeData(buf, bufSize, seg.sp+seg.ds);
 | 
				
			||||||
    seg.ds += bufSize;
 | 
					    seg.ds += bufSize;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  // calculate downloading speed
 | 
				
			||||||
 | 
					  struct timeval now;
 | 
				
			||||||
 | 
					  gettimeofday(&now, NULL);
 | 
				
			||||||
 | 
					  if(sw.tv_sec == 0 && sw.tv_usec == 0) {
 | 
				
			||||||
 | 
					    sw = now;
 | 
				
			||||||
 | 
					    lastSize = seg.ds;
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    long long int diff = Util::difftv(now, sw);
 | 
				
			||||||
 | 
					    if(diff >= 1000000) {
 | 
				
			||||||
 | 
					      seg.speed = (int)((seg.ds-lastSize)/(diff/1000000.0));
 | 
				
			||||||
 | 
					      sw = now;
 | 
				
			||||||
 | 
					      lastSize = seg.ds;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  if(te != NULL && te->finished()
 | 
					  if(te != NULL && te->finished()
 | 
				
			||||||
     || te == NULL && seg.ds >= seg.ep-seg.sp+1
 | 
					     || te == NULL && seg.ds >= seg.ep-seg.sp+1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,6 +29,9 @@
 | 
				
			||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DownloadCommand : public AbstractCommand {
 | 
					class DownloadCommand : public AbstractCommand {
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					  struct timeval sw;
 | 
				
			||||||
 | 
					  long long int lastSize;
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
  bool executeInternal(Segment segment);
 | 
					  bool executeInternal(Segment segment);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -113,7 +113,7 @@ int FtpConnection::getStatus(string response) const {
 | 
				
			||||||
  // When the response is not like "%d %*s",
 | 
					  // When the response is not like "%d %*s",
 | 
				
			||||||
  // we return 0.
 | 
					  // we return 0.
 | 
				
			||||||
  if(response.find_first_not_of("0123456789") != 3
 | 
					  if(response.find_first_not_of("0123456789") != 3
 | 
				
			||||||
     || response.find(" ") != 3) {
 | 
					     || !(response.find(" ") == 3 || response.find("-") == 3)) {
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  if(sscanf(response.c_str(), "%d %*s", &status) == 1) {
 | 
					  if(sscanf(response.c_str(), "%d %*s", &status) == 1) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,9 @@ SRCS =  Socket.cc Socket.h\
 | 
				
			||||||
	DownloadEngine.cc DownloadEngine.h\
 | 
						DownloadEngine.cc DownloadEngine.h\
 | 
				
			||||||
	Segment.h\
 | 
						Segment.h\
 | 
				
			||||||
	SegmentMan.cc SegmentMan.h\
 | 
						SegmentMan.cc SegmentMan.h\
 | 
				
			||||||
 | 
						SegmentSplitter.cc SegmentSplitter.h\
 | 
				
			||||||
 | 
						SplitFirstSegmentSplitter.cc SplitFirstSegmentSplitter.h\
 | 
				
			||||||
 | 
						SplitSlowestSegmentSplitter.cc SplitSlowestSegmentSplitter.h\
 | 
				
			||||||
	Util.cc Util.h\
 | 
						Util.cc Util.h\
 | 
				
			||||||
	Request.cc Request.h\
 | 
						Request.cc Request.h\
 | 
				
			||||||
	common.h\
 | 
						common.h\
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,8 +71,11 @@ am__objects_1 = libaria2c_a-Socket.$(OBJEXT) \
 | 
				
			||||||
	libaria2c_a-FtpTunnelResponseCommand.$(OBJEXT) \
 | 
						libaria2c_a-FtpTunnelResponseCommand.$(OBJEXT) \
 | 
				
			||||||
	libaria2c_a-SleepCommand.$(OBJEXT) \
 | 
						libaria2c_a-SleepCommand.$(OBJEXT) \
 | 
				
			||||||
	libaria2c_a-DownloadEngine.$(OBJEXT) \
 | 
						libaria2c_a-DownloadEngine.$(OBJEXT) \
 | 
				
			||||||
	libaria2c_a-SegmentMan.$(OBJEXT) libaria2c_a-Util.$(OBJEXT) \
 | 
						libaria2c_a-SegmentMan.$(OBJEXT) \
 | 
				
			||||||
	libaria2c_a-Request.$(OBJEXT) \
 | 
						libaria2c_a-SegmentSplitter.$(OBJEXT) \
 | 
				
			||||||
 | 
						libaria2c_a-SplitFirstSegmentSplitter.$(OBJEXT) \
 | 
				
			||||||
 | 
						libaria2c_a-SplitSlowestSegmentSplitter.$(OBJEXT) \
 | 
				
			||||||
 | 
						libaria2c_a-Util.$(OBJEXT) libaria2c_a-Request.$(OBJEXT) \
 | 
				
			||||||
	libaria2c_a-SimpleLogger.$(OBJEXT) \
 | 
						libaria2c_a-SimpleLogger.$(OBJEXT) \
 | 
				
			||||||
	libaria2c_a-ChunkedEncoding.$(OBJEXT) \
 | 
						libaria2c_a-ChunkedEncoding.$(OBJEXT) \
 | 
				
			||||||
	libaria2c_a-DefaultDiskWriter.$(OBJEXT) \
 | 
						libaria2c_a-DefaultDiskWriter.$(OBJEXT) \
 | 
				
			||||||
| 
						 | 
					@ -211,6 +214,9 @@ SRCS = Socket.cc Socket.h\
 | 
				
			||||||
	DownloadEngine.cc DownloadEngine.h\
 | 
						DownloadEngine.cc DownloadEngine.h\
 | 
				
			||||||
	Segment.h\
 | 
						Segment.h\
 | 
				
			||||||
	SegmentMan.cc SegmentMan.h\
 | 
						SegmentMan.cc SegmentMan.h\
 | 
				
			||||||
 | 
						SegmentSplitter.cc SegmentSplitter.h\
 | 
				
			||||||
 | 
						SplitFirstSegmentSplitter.cc SplitFirstSegmentSplitter.h\
 | 
				
			||||||
 | 
						SplitSlowestSegmentSplitter.cc SplitSlowestSegmentSplitter.h\
 | 
				
			||||||
	Util.cc Util.h\
 | 
						Util.cc Util.h\
 | 
				
			||||||
	Request.cc Request.h\
 | 
						Request.cc Request.h\
 | 
				
			||||||
	common.h\
 | 
						common.h\
 | 
				
			||||||
| 
						 | 
					@ -337,10 +343,13 @@ distclean-compile:
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-Option.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-Option.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-Request.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-Request.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SegmentMan.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SegmentMan.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SegmentSplitter.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SimpleLogger.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SimpleLogger.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SleepCommand.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SleepCommand.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-Socket.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-Socket.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SocketCore.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SocketCore.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Po@am__quote@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Po@am__quote@
 | 
				
			||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-Util.Po@am__quote@
 | 
					@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libaria2c_a-Util.Po@am__quote@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.cc.o:
 | 
					.cc.o:
 | 
				
			||||||
| 
						 | 
					@ -665,6 +674,48 @@ libaria2c_a-SegmentMan.obj: SegmentMan.cc
 | 
				
			||||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -c -o libaria2c_a-SegmentMan.obj `if test -f 'SegmentMan.cc'; then $(CYGPATH_W) 'SegmentMan.cc'; else $(CYGPATH_W) '$(srcdir)/SegmentMan.cc'; fi`
 | 
					@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -c -o libaria2c_a-SegmentMan.obj `if test -f 'SegmentMan.cc'; then $(CYGPATH_W) 'SegmentMan.cc'; else $(CYGPATH_W) '$(srcdir)/SegmentMan.cc'; fi`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					libaria2c_a-SegmentSplitter.o: SegmentSplitter.cc
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -MT libaria2c_a-SegmentSplitter.o -MD -MP -MF "$(DEPDIR)/libaria2c_a-SegmentSplitter.Tpo" -c -o libaria2c_a-SegmentSplitter.o `test -f 'SegmentSplitter.cc' || echo '$(srcdir)/'`SegmentSplitter.cc; \
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libaria2c_a-SegmentSplitter.Tpo" "$(DEPDIR)/libaria2c_a-SegmentSplitter.Po"; else rm -f "$(DEPDIR)/libaria2c_a-SegmentSplitter.Tpo"; exit 1; fi
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='SegmentSplitter.cc' object='libaria2c_a-SegmentSplitter.o' libtool=no @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -c -o libaria2c_a-SegmentSplitter.o `test -f 'SegmentSplitter.cc' || echo '$(srcdir)/'`SegmentSplitter.cc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					libaria2c_a-SegmentSplitter.obj: SegmentSplitter.cc
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -MT libaria2c_a-SegmentSplitter.obj -MD -MP -MF "$(DEPDIR)/libaria2c_a-SegmentSplitter.Tpo" -c -o libaria2c_a-SegmentSplitter.obj `if test -f 'SegmentSplitter.cc'; then $(CYGPATH_W) 'SegmentSplitter.cc'; else $(CYGPATH_W) '$(srcdir)/SegmentSplitter.cc'; fi`; \
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libaria2c_a-SegmentSplitter.Tpo" "$(DEPDIR)/libaria2c_a-SegmentSplitter.Po"; else rm -f "$(DEPDIR)/libaria2c_a-SegmentSplitter.Tpo"; exit 1; fi
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='SegmentSplitter.cc' object='libaria2c_a-SegmentSplitter.obj' libtool=no @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -c -o libaria2c_a-SegmentSplitter.obj `if test -f 'SegmentSplitter.cc'; then $(CYGPATH_W) 'SegmentSplitter.cc'; else $(CYGPATH_W) '$(srcdir)/SegmentSplitter.cc'; fi`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					libaria2c_a-SplitFirstSegmentSplitter.o: SplitFirstSegmentSplitter.cc
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -MT libaria2c_a-SplitFirstSegmentSplitter.o -MD -MP -MF "$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Tpo" -c -o libaria2c_a-SplitFirstSegmentSplitter.o `test -f 'SplitFirstSegmentSplitter.cc' || echo '$(srcdir)/'`SplitFirstSegmentSplitter.cc; \
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Tpo" "$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Po"; else rm -f "$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Tpo"; exit 1; fi
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='SplitFirstSegmentSplitter.cc' object='libaria2c_a-SplitFirstSegmentSplitter.o' libtool=no @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -c -o libaria2c_a-SplitFirstSegmentSplitter.o `test -f 'SplitFirstSegmentSplitter.cc' || echo '$(srcdir)/'`SplitFirstSegmentSplitter.cc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					libaria2c_a-SplitFirstSegmentSplitter.obj: SplitFirstSegmentSplitter.cc
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -MT libaria2c_a-SplitFirstSegmentSplitter.obj -MD -MP -MF "$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Tpo" -c -o libaria2c_a-SplitFirstSegmentSplitter.obj `if test -f 'SplitFirstSegmentSplitter.cc'; then $(CYGPATH_W) 'SplitFirstSegmentSplitter.cc'; else $(CYGPATH_W) '$(srcdir)/SplitFirstSegmentSplitter.cc'; fi`; \
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Tpo" "$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Po"; else rm -f "$(DEPDIR)/libaria2c_a-SplitFirstSegmentSplitter.Tpo"; exit 1; fi
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='SplitFirstSegmentSplitter.cc' object='libaria2c_a-SplitFirstSegmentSplitter.obj' libtool=no @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -c -o libaria2c_a-SplitFirstSegmentSplitter.obj `if test -f 'SplitFirstSegmentSplitter.cc'; then $(CYGPATH_W) 'SplitFirstSegmentSplitter.cc'; else $(CYGPATH_W) '$(srcdir)/SplitFirstSegmentSplitter.cc'; fi`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					libaria2c_a-SplitSlowestSegmentSplitter.o: SplitSlowestSegmentSplitter.cc
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -MT libaria2c_a-SplitSlowestSegmentSplitter.o -MD -MP -MF "$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Tpo" -c -o libaria2c_a-SplitSlowestSegmentSplitter.o `test -f 'SplitSlowestSegmentSplitter.cc' || echo '$(srcdir)/'`SplitSlowestSegmentSplitter.cc; \
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Tpo" "$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Po"; else rm -f "$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Tpo"; exit 1; fi
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='SplitSlowestSegmentSplitter.cc' object='libaria2c_a-SplitSlowestSegmentSplitter.o' libtool=no @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -c -o libaria2c_a-SplitSlowestSegmentSplitter.o `test -f 'SplitSlowestSegmentSplitter.cc' || echo '$(srcdir)/'`SplitSlowestSegmentSplitter.cc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					libaria2c_a-SplitSlowestSegmentSplitter.obj: SplitSlowestSegmentSplitter.cc
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -MT libaria2c_a-SplitSlowestSegmentSplitter.obj -MD -MP -MF "$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Tpo" -c -o libaria2c_a-SplitSlowestSegmentSplitter.obj `if test -f 'SplitSlowestSegmentSplitter.cc'; then $(CYGPATH_W) 'SplitSlowestSegmentSplitter.cc'; else $(CYGPATH_W) '$(srcdir)/SplitSlowestSegmentSplitter.cc'; fi`; \
 | 
				
			||||||
 | 
					@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Tpo" "$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Po"; else rm -f "$(DEPDIR)/libaria2c_a-SplitSlowestSegmentSplitter.Tpo"; exit 1; fi
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='SplitSlowestSegmentSplitter.cc' object='libaria2c_a-SplitSlowestSegmentSplitter.obj' libtool=no @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 | 
				
			||||||
 | 
					@am__fastdepCXX_FALSE@	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -c -o libaria2c_a-SplitSlowestSegmentSplitter.obj `if test -f 'SplitSlowestSegmentSplitter.cc'; then $(CYGPATH_W) 'SplitSlowestSegmentSplitter.cc'; else $(CYGPATH_W) '$(srcdir)/SplitSlowestSegmentSplitter.cc'; fi`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
libaria2c_a-Util.o: Util.cc
 | 
					libaria2c_a-Util.o: Util.cc
 | 
				
			||||||
@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -MT libaria2c_a-Util.o -MD -MP -MF "$(DEPDIR)/libaria2c_a-Util.Tpo" -c -o libaria2c_a-Util.o `test -f 'Util.cc' || echo '$(srcdir)/'`Util.cc; \
 | 
					@am__fastdepCXX_TRUE@	if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libaria2c_a_CXXFLAGS) $(CXXFLAGS) -MT libaria2c_a-Util.o -MD -MP -MF "$(DEPDIR)/libaria2c_a-Util.Tpo" -c -o libaria2c_a-Util.o `test -f 'Util.cc' || echo '$(srcdir)/'`Util.cc; \
 | 
				
			||||||
@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libaria2c_a-Util.Tpo" "$(DEPDIR)/libaria2c_a-Util.Po"; else rm -f "$(DEPDIR)/libaria2c_a-Util.Tpo"; exit 1; fi
 | 
					@am__fastdepCXX_TRUE@	then mv -f "$(DEPDIR)/libaria2c_a-Util.Tpo" "$(DEPDIR)/libaria2c_a-Util.Po"; else rm -f "$(DEPDIR)/libaria2c_a-Util.Tpo"; exit 1; fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,10 @@
 | 
				
			||||||
#ifndef _D_SEGMENT_H_
 | 
					#ifndef _D_SEGMENT_H_
 | 
				
			||||||
#define _D_SEGMENT_H_
 | 
					#define _D_SEGMENT_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Segment represents a download segment.
 | 
					 * Segment represents a download segment.
 | 
				
			||||||
 * sp, ep is a offset from a begining of a file.
 | 
					 * sp, ep is a offset from a begining of a file.
 | 
				
			||||||
| 
						 | 
					@ -36,9 +40,12 @@ typedef struct {
 | 
				
			||||||
  long long int sp;
 | 
					  long long int sp;
 | 
				
			||||||
  long long int ep;
 | 
					  long long int ep;
 | 
				
			||||||
  long long int ds;
 | 
					  long long int ds;
 | 
				
			||||||
 | 
					  int speed;
 | 
				
			||||||
  bool finish;
 | 
					  bool finish;
 | 
				
			||||||
} Segment;
 | 
					} Segment;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef vector<Segment> Segments;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SEGMENT_EQUAL(X, Y) (X.cuid == Y.cuid && X.sp == Y.sp && X.ep == Y.ep && X.ds == Y.ds && X.finish == Y.finish ? true : false)
 | 
					#define SEGMENT_EQUAL(X, Y) (X.cuid == Y.cuid && X.sp == Y.sp && X.ep == Y.ep && X.ds == Y.ds && X.finish == Y.finish ? true : false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // _D_SEGMENT_H_
 | 
					#endif // _D_SEGMENT_H_
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,6 +52,7 @@ bool SegmentMan::getSegment(Segment& seg, int cuid) {
 | 
				
			||||||
    seg.sp = 0;
 | 
					    seg.sp = 0;
 | 
				
			||||||
    seg.ep = totalSize == 0 ? 0 : totalSize-1;
 | 
					    seg.ep = totalSize == 0 ? 0 : totalSize-1;
 | 
				
			||||||
    seg.ds = 0;
 | 
					    seg.ds = 0;
 | 
				
			||||||
 | 
					    seg.speed = 0;
 | 
				
			||||||
    seg.finish = false;
 | 
					    seg.finish = false;
 | 
				
			||||||
    segments.push_back(seg);
 | 
					    segments.push_back(seg);
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
| 
						 | 
					@ -81,35 +82,7 @@ bool SegmentMan::getSegment(Segment& seg, int cuid) {
 | 
				
			||||||
      return true;
 | 
					      return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  for(vector<Segment>::iterator itr = segments.begin(); itr != segments.end(); itr++) {
 | 
					  return splitter->splitSegment(seg, cuid, segments);
 | 
				
			||||||
    Segment& s = *itr;
 | 
					 | 
				
			||||||
    if(s.finish) {
 | 
					 | 
				
			||||||
      continue;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if(s.ep-(s.sp+s.ds) > option->getAsLLInt(PREF_MIN_SEGMENT_SIZE)) {
 | 
					 | 
				
			||||||
      long long int nep = (s.ep-(s.sp+s.ds))/2+(s.sp+s.ds);
 | 
					 | 
				
			||||||
      //nseg = { cuid, nep+1, s.ep, 0, false };
 | 
					 | 
				
			||||||
      seg.cuid = cuid;
 | 
					 | 
				
			||||||
      seg.sp = nep+1;
 | 
					 | 
				
			||||||
      seg.ep = s.ep;
 | 
					 | 
				
			||||||
      seg.ds = 0;
 | 
					 | 
				
			||||||
      seg.finish = false;
 | 
					 | 
				
			||||||
      s.ep = nep;
 | 
					 | 
				
			||||||
      logger->debug("return new segment { "
 | 
					 | 
				
			||||||
		    "sp = "+Util::llitos(seg.sp)+", "+
 | 
					 | 
				
			||||||
		    "ep = "+Util::llitos(seg.ep)+", "
 | 
					 | 
				
			||||||
		    "ds = "+Util::llitos(seg.ds)+" } to "+
 | 
					 | 
				
			||||||
		    "cuid "+Util::llitos(cuid));
 | 
					 | 
				
			||||||
      logger->debug("update segment { "
 | 
					 | 
				
			||||||
		    "sp = "+Util::llitos(s.sp)+", "+
 | 
					 | 
				
			||||||
		    "ep = "+Util::llitos(s.ep)+", "
 | 
					 | 
				
			||||||
		    "ds = "+Util::llitos(s.ds)+" } of "+
 | 
					 | 
				
			||||||
		    "cuid "+Util::llitos(s.cuid));
 | 
					 | 
				
			||||||
      segments.push_back(seg);
 | 
					 | 
				
			||||||
      return true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return false;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void SegmentMan::updateSegment(const Segment& segment) {
 | 
					void SegmentMan::updateSegment(const Segment& segment) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,6 +27,7 @@
 | 
				
			||||||
#include "Logger.h"
 | 
					#include "Logger.h"
 | 
				
			||||||
#include "Segment.h"
 | 
					#include "Segment.h"
 | 
				
			||||||
#include "Option.h"
 | 
					#include "Option.h"
 | 
				
			||||||
 | 
					#include "SegmentSplitter.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -64,7 +65,7 @@ public:
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Holds segments.
 | 
					   * Holds segments.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  vector<Segment> segments;
 | 
					  Segments segments;
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Respresents the file name of the downloaded file.
 | 
					   * Respresents the file name of the downloaded file.
 | 
				
			||||||
   * If the URL does not contain file name part(http://www.rednoah.com/, for 
 | 
					   * If the URL does not contain file name part(http://www.rednoah.com/, for 
 | 
				
			||||||
| 
						 | 
					@ -83,6 +84,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const Logger* logger;
 | 
					  const Logger* logger;
 | 
				
			||||||
  const Option* option;
 | 
					  const Option* option;
 | 
				
			||||||
 | 
					  SegmentSplitter* splitter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  SegmentMan();
 | 
					  SegmentMan();
 | 
				
			||||||
  ~SegmentMan();
 | 
					  ~SegmentMan();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,7 @@ public:
 | 
				
			||||||
  static string llitos(long long int value, bool comma = false);
 | 
					  static string llitos(long long int value, bool comma = false);
 | 
				
			||||||
  static string itos(int value, bool comma = false);
 | 
					  static string itos(int value, bool comma = false);
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Computes difference in milli second between tv1 and tv2,
 | 
					   * Computes difference in micro-seconds between tv1 and tv2,
 | 
				
			||||||
   * assuming tv1 is newer than tv2.
 | 
					   * assuming tv1 is newer than tv2.
 | 
				
			||||||
   * If tv1 is older than tv2, then this method returns 0.
 | 
					   * If tv1 is older than tv2, then this method returns 0.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
#include "HttpInitiateConnectionCommand.h"
 | 
					#include "HttpInitiateConnectionCommand.h"
 | 
				
			||||||
#include "DownloadEngine.h"
 | 
					#include "DownloadEngine.h"
 | 
				
			||||||
#include "SegmentMan.h"
 | 
					#include "SegmentMan.h"
 | 
				
			||||||
 | 
					#include "SplitSlowestSegmentSplitter.h"
 | 
				
			||||||
#include "SimpleLogger.h"
 | 
					#include "SimpleLogger.h"
 | 
				
			||||||
#include "common.h"
 | 
					#include "common.h"
 | 
				
			||||||
#include "DefaultDiskWriter.h"
 | 
					#include "DefaultDiskWriter.h"
 | 
				
			||||||
| 
						 | 
					@ -106,7 +107,7 @@ void showUsage() {
 | 
				
			||||||
  cout << " -l, --log=LOG                The file path to store log. If '-' is specified," << endl;
 | 
					  cout << " -l, --log=LOG                The file path to store log. If '-' is specified," << endl;
 | 
				
			||||||
  cout << "                              log is written to stdout." << endl;
 | 
					  cout << "                              log is written to stdout." << endl;
 | 
				
			||||||
  cout << " -D, --daemon                 Run as daemon." << endl;
 | 
					  cout << " -D, --daemon                 Run as daemon." << endl;
 | 
				
			||||||
  cout << " -s, --split=N                Download a file using s connections. s must be" << endl;
 | 
					  cout << " -s, --split=N                Download a file using N connections. N must be" << endl;
 | 
				
			||||||
  cout << "                              between 1 and 5. This option affects all URLs." << endl;
 | 
					  cout << "                              between 1 and 5. This option affects all URLs." << endl;
 | 
				
			||||||
  cout << "                              Thus, aria2 connects to each URL with N connections." << endl;
 | 
					  cout << "                              Thus, aria2 connects to each URL with N connections." << endl;
 | 
				
			||||||
  cout << " --retry-wait=SEC             Set amount of time in second between requests" << endl;
 | 
					  cout << " --retry-wait=SEC             Set amount of time in second between requests" << endl;
 | 
				
			||||||
| 
						 | 
					@ -138,6 +139,7 @@ void showUsage() {
 | 
				
			||||||
  cout << " -p, --ftp-pasv               Use passive mode in FTP." << endl;
 | 
					  cout << " -p, --ftp-pasv               Use passive mode in FTP." << endl;
 | 
				
			||||||
  cout << " --ftp-via-http-proxy=WAY     Use HTTP proxy in FTP. WAY is either 'get' or" << endl;
 | 
					  cout << " --ftp-via-http-proxy=WAY     Use HTTP proxy in FTP. WAY is either 'get' or" << endl;
 | 
				
			||||||
  cout << "                              'tunnel'." << endl;
 | 
					  cout << "                              'tunnel'." << endl;
 | 
				
			||||||
 | 
					  cout << "                              Default: tunnel" << endl;
 | 
				
			||||||
  cout << " -v, --version                Print the version number and exit." << endl;
 | 
					  cout << " -v, --version                Print the version number and exit." << endl;
 | 
				
			||||||
  cout << " -h, --help                   Print this message and exit." << endl;
 | 
					  cout << " -h, --help                   Print this message and exit." << endl;
 | 
				
			||||||
  cout << endl;
 | 
					  cout << endl;
 | 
				
			||||||
| 
						 | 
					@ -176,7 +178,6 @@ int main(int argc, char* argv[]) {
 | 
				
			||||||
  op->put(PREF_FTP_USER, "anonymous");
 | 
					  op->put(PREF_FTP_USER, "anonymous");
 | 
				
			||||||
  op->put(PREF_FTP_PASSWD, "ARIA2USER@");
 | 
					  op->put(PREF_FTP_PASSWD, "ARIA2USER@");
 | 
				
			||||||
  op->put(PREF_FTP_TYPE, V_BINARY);
 | 
					  op->put(PREF_FTP_TYPE, V_BINARY);
 | 
				
			||||||
  op->put(PREF_FTP_PASV_ENABLED, V_TRUE);
 | 
					 | 
				
			||||||
  op->put(PREF_FTP_VIA_HTTP_PROXY, V_TUNNEL);
 | 
					  op->put(PREF_FTP_VIA_HTTP_PROXY, V_TUNNEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while(1) {
 | 
					  while(1) {
 | 
				
			||||||
| 
						 | 
					@ -393,6 +394,9 @@ int main(int argc, char* argv[]) {
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    logger = new SimpleLogger("/dev/null");
 | 
					    logger = new SimpleLogger("/dev/null");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  SegmentSplitter* splitter = new SplitSlowestSegmentSplitter();
 | 
				
			||||||
 | 
					  splitter->setMinSegmentSize(op->getAsLLInt(PREF_MIN_SEGMENT_SIZE));
 | 
				
			||||||
 | 
					  splitter->logger = logger;
 | 
				
			||||||
  e = new DownloadEngine();
 | 
					  e = new DownloadEngine();
 | 
				
			||||||
  e->logger = logger;
 | 
					  e->logger = logger;
 | 
				
			||||||
  e->option = op;
 | 
					  e->option = op;
 | 
				
			||||||
| 
						 | 
					@ -402,6 +406,7 @@ int main(int argc, char* argv[]) {
 | 
				
			||||||
  e->segmentMan->ufilename = ufilename;
 | 
					  e->segmentMan->ufilename = ufilename;
 | 
				
			||||||
  e->segmentMan->logger = logger;
 | 
					  e->segmentMan->logger = logger;
 | 
				
			||||||
  e->segmentMan->option = op;
 | 
					  e->segmentMan->option = op;
 | 
				
			||||||
 | 
					  e->segmentMan->splitter = splitter;
 | 
				
			||||||
  vector<Request*> requests;
 | 
					  vector<Request*> requests;
 | 
				
			||||||
  for(int i = 1; optind+i-1 < argc; i++) {
 | 
					  for(int i = 1; optind+i-1 < argc; i++) {
 | 
				
			||||||
    for(int s = 1; s <= split; s++) {
 | 
					    for(int s = 1; s <= split; s++) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue