Browse Source

2010-04-02 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Added forceHalt argument to TimedHaltCommand.
	Added requestForceHalt() to DownloadEngine.
	* src/DownloadEngine.cc
	* src/DownloadEngine.h
	* src/TimedHaltCommand.cc
	* src/TimedHaltCommand.h
Tatsuhiro Tsujikawa 15 năm trước cách đây
mục cha
commit
730f7449ae
5 tập tin đã thay đổi với 31 bổ sung4 xóa
  1. 9 0
      ChangeLog
  2. 6 0
      src/DownloadEngine.cc
  3. 2 0
      src/DownloadEngine.h
  4. 10 3
      src/TimedHaltCommand.cc
  5. 4 1
      src/TimedHaltCommand.h

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+2010-04-02  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Added forceHalt argument to TimedHaltCommand.
+	Added requestForceHalt() to DownloadEngine.
+	* src/DownloadEngine.cc
+	* src/DownloadEngine.h
+	* src/TimedHaltCommand.cc
+	* src/TimedHaltCommand.h
+
 2010-04-02  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Possible fix for chunked encoding with Content-Length.

+ 6 - 0
src/DownloadEngine.cc

@@ -241,6 +241,12 @@ void DownloadEngine::requestHalt()
   _requestGroupMan->halt();
 }
 
+void DownloadEngine::requestForceHalt()
+{
+  _haltRequested = true;
+  _requestGroupMan->forceHalt();
+}
+
 void DownloadEngine::setStatCalc(const StatCalcHandle& statCalc)
 {
   _statCalc = statCalc;

+ 2 - 0
src/DownloadEngine.h

@@ -196,6 +196,8 @@ public:
 
   void requestHalt();
 
+  void requestForceHalt();
+
   void setNoWait(bool b);
 
   void addRoutineCommand(Command* command);

+ 10 - 3
src/TimedHaltCommand.cc

@@ -42,8 +42,10 @@
 namespace aria2 {
 
 TimedHaltCommand::TimedHaltCommand(cuid_t cuid, DownloadEngine* e,
-                                   time_t secondsToHalt):
-  TimeBasedCommand(cuid, e, secondsToHalt, true) {}
+                                   time_t secondsToHalt,
+                                   bool forceHalt):
+  TimeBasedCommand(cuid, e, secondsToHalt, true),
+  _forceHalt(forceHalt) {}
 
 TimedHaltCommand::~TimedHaltCommand() {}
 
@@ -58,7 +60,12 @@ void TimedHaltCommand::process()
 {
   if(!_e->isHaltRequested()) {
     logger->notice(MSG_TIME_HAS_PASSED, _interval);
-    _e->requestHalt();
+    if(_forceHalt) {
+      _e->requestForceHalt();
+    } else {
+      _e->requestHalt();
+    }
+    _exit = true;
   }
 }
 

+ 4 - 1
src/TimedHaltCommand.h

@@ -40,8 +40,11 @@
 namespace aria2 {
 
 class TimedHaltCommand:public TimeBasedCommand {
+private:
+  bool _forceHalt;
 public:
-  TimedHaltCommand(cuid_t cuid, DownloadEngine* e, time_t secondsToHalt);
+  TimedHaltCommand
+  (cuid_t cuid, DownloadEngine* e, time_t secondsToHalt, bool forceHalt=false);
 
   virtual ~TimedHaltCommand();