فهرست منبع

2010-07-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Moved segment empty check before socket check.
	* src/AbstractCommand.cc
Tatsuhiro Tsujikawa 15 سال پیش
والد
کامیت
bd73c20c4d
2فایلهای تغییر یافته به همراه26 افزوده شده و 21 حذف شده
  1. 5 0
      ChangeLog
  2. 21 21
      src/AbstractCommand.cc

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2010-07-11  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Moved segment empty check before socket check.
+	* src/AbstractCommand.cc
+
 2010-07-11  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Fixed the bug that segments are not filled to

+ 21 - 21
src/AbstractCommand.cc

@@ -125,6 +125,27 @@ bool AbstractCommand::execute() {
       }
       return prepareForRetry(0);
     }
+    if(!getPieceStorage().isNull()) {
+      segments_.clear();
+      getSegmentMan()->getInFlightSegment(segments_, getCuid());
+      if(!req_.isNull() && segments_.empty()) {
+        // This command previously has assigned segments, but it is
+        // canceled. So discard current request chain.  Plus, if no
+        // segment is available when http pipelining is used.
+        if(getLogger()->debug()) {
+          getLogger()->debug("CUID#%s - It seems previously assigned segments"
+                             " are canceled. Restart.",
+                             util::itos(getCuid()).c_str());
+        }
+        // Request::isPipeliningEnabled() == true means aria2
+        // accessed the remote server and discovered that the server
+        // supports pipelining.
+        if(!req_.isNull() && req_->isPipeliningEnabled()) {
+          e_->poolSocket(req_, createProxyRequest(), socket_);
+        }
+        return prepareForRetry(0);
+      }
+    }
     // TODO it is not needed to check other PeerStats every time.
     // Find faster Request when no segment is available.
     if(!req_.isNull() && fileEntry_->countPooledRequest() > 0 &&
@@ -157,27 +178,6 @@ bool AbstractCommand::execute() {
         !nameResolverCheck_)) {
       checkPoint_ = global::wallclock;
       if(!getPieceStorage().isNull()) {
-        segments_.clear();
-        getSegmentMan()->getInFlightSegment(segments_, getCuid());
-        if(!req_.isNull() && segments_.empty()) {
-          // TODO make this out side of socket check if.
-
-          // This command previously has assigned segments, but it is
-          // canceled. So discard current request chain.  Plus, if no
-          // segment is available when http pipelining is used.
-          if(getLogger()->debug()) {
-            getLogger()->debug("CUID#%s - It seems previously assigned segments"
-                               " are canceled. Restart.",
-                               util::itos(getCuid()).c_str());
-          }
-          // Request::isPipeliningEnabled() == true means aria2
-          // accessed the remote server and discovered that the server
-          // supports pipelining.
-          if(!req_.isNull() && req_->isPipeliningEnabled()) {
-            e_->poolSocket(req_, createProxyRequest(), socket_);
-          }
-          return prepareForRetry(0);
-        }
         if(req_.isNull() || req_->getMaxPipelinedRequest() == 1 ||
            // Why the following condition is necessary? That's because
            // For single file download, SegmentMan::getSegment(cuid)