Browse Source

2008-09-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	If error event is received in epoll, then abort download 
immediately.
	* src/AbstractCommand.cc
	* src/Command.cc
	* src/Command.h
	* src/DownloadEngine.cc
	* src/PeerAbstractCommand.cc
Tatsuhiro Tsujikawa 17 years ago
parent
commit
0680ac5e5e
6 changed files with 33 additions and 7 deletions
  1. 9 0
      ChangeLog
  2. 3 1
      src/AbstractCommand.cc
  3. 9 2
      src/Command.cc
  4. 4 1
      src/Command.h
  5. 5 2
      src/DownloadEngine.cc
  6. 3 1
      src/PeerAbstractCommand.cc

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+2008-09-14  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	If error event is received in epoll, then abort download immediately.
+	* src/AbstractCommand.cc
+	* src/Command.cc
+	* src/Command.h
+	* src/DownloadEngine.cc
+	* src/PeerAbstractCommand.cc
+	
 2008-09-14  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Added usage message for --uri-selector, --server-stat-of,

+ 3 - 1
src/AbstractCommand.cc

@@ -107,7 +107,7 @@ bool AbstractCommand::execute() {
     }
     if((checkSocketIsReadable && _readEvent) ||
        (checkSocketIsWritable && _writeEvent) ||
-       _errorEvent ||
+       _hupEvent ||
 #ifdef ENABLE_ASYNC_DNS
        (nameResolverCheck && nameResolveFinished()) ||
 #endif // ENABLE_ASYNC_DNS
@@ -136,6 +136,8 @@ bool AbstractCommand::execute() {
 	}
       }
       return executeInternal();
+    } else if(_errorEvent) {
+      throw DlRetryEx("Network problem has occurred.");
     } else {
       if(checkPoint.elapsed(timeout)) {
 	// timeout triggers ServerStat error state.

+ 9 - 2
src/Command.cc

@@ -46,7 +46,8 @@ Command::Command(int32_t cuid):uuid(uuidGen++),
 			       logger(LogFactory::getInstance()),
 			       _readEvent(false),
 			       _writeEvent(false),
-			       _errorEvent(false) {}
+			       _errorEvent(false),
+			       _hupEvent(false) {}
 
 void Command::transitStatus()
 {
@@ -73,16 +74,22 @@ void Command::writeEventReceived()
   _writeEvent = true;
 }
 
-void Command::errorEventRecieved()
+void Command::errorEventReceived()
 {
   _errorEvent = true;
 }
 
+void Command::hupEventReceived()
+{
+  _hupEvent = true;
+}
+
 void Command::clearIOEvents()
 {
   _readEvent = false;
   _writeEvent = false;
   _errorEvent = false;
+  _hupEvent = false;
 }
 
 } // namespace aria2

+ 4 - 1
src/Command.h

@@ -65,6 +65,7 @@ protected:
   bool _readEvent;
   bool _writeEvent;
   bool _errorEvent;
+  bool _hupEvent;
 public:
   Command(int32_t cuid);
 
@@ -95,7 +96,9 @@ public:
 
   void writeEventReceived();
 
-  void errorEventRecieved();
+  void errorEventReceived();
+
+  void hupEventReceived();
 
   void clearIOEvents();
 };

+ 5 - 2
src/DownloadEngine.cc

@@ -109,8 +109,11 @@ void CommandEvent::processEvents(int events)
   if(SocketEntry::EVENT_WRITE&events) {
     _command->writeEventReceived();
   }
-  if((SocketEntry::EVENT_ERROR|SocketEntry::EVENT_HUP)&events) {
-    _command->errorEventRecieved();
+  if(SocketEntry::EVENT_ERROR&events) {
+    _command->errorEventReceived();
+  }
+  if(SocketEntry::EVENT_HUP&events) {
+    _command->hupEventReceived();
   }
 }
 

+ 3 - 1
src/PeerAbstractCommand.cc

@@ -81,8 +81,10 @@ bool PeerAbstractCommand::execute()
     if(noCheck ||
        (checkSocketIsReadable && _readEvent) ||
        (checkSocketIsWritable && _writeEvent) ||
-       _errorEvent) {
+       _hupEvent) {
       checkPoint.reset();
+    } else if(_errorEvent) {
+      throw DlAbortEx("Network problem has occurred.");
     }
     if(checkPoint.elapsed(timeout)) {
       throw DlAbortEx(EX_TIME_OUT);