Bläddra i källkod

2008-05-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Pool connection when CWD, SIZE command fails.
	* src/FtpNegotiationCommand.cc
	* src/FtpNegotiationCommand.h
Tatsuhiro Tsujikawa 17 år sedan
förälder
incheckning
e71b09a9dc
3 ändrade filer med 21 tillägg och 4 borttagningar
  1. 6 0
      ChangeLog
  2. 13 4
      src/FtpNegotiationCommand.cc
  3. 2 0
      src/FtpNegotiationCommand.h

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2008-05-10  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Pool connection when CWD, SIZE command fails.
+	* src/FtpNegotiationCommand.cc
+	* src/FtpNegotiationCommand.h
+
 2008-05-10  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Renamed HttpNullDownloadCommand as HttpSkipResponseCommand

+ 13 - 4
src/FtpNegotiationCommand.cc

@@ -193,6 +193,7 @@ bool FtpNegotiationCommand::recvCwd() {
     return false;
   }
   if(status != 250) {
+    poolConnection();
     throw DlAbortEx(StringFormat(EX_BAD_STATUS, status).str());
   }
   sequence = SEQ_SEND_SIZE;
@@ -212,6 +213,7 @@ bool FtpNegotiationCommand::recvSize() {
     return false;
   }
   if(status != 213) {
+    poolConnection();
     throw DlAbortEx(StringFormat(EX_BAD_STATUS, status).str());
   }
   if(size > INT64_MAX) {
@@ -241,10 +243,8 @@ bool FtpNegotiationCommand::recvSize() {
     BtProgressInfoFileHandle infoFile(new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option));
     if(!infoFile->exists() && _requestGroup->downloadFinishedByFileLength()) {
       sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
-      // We can pool socket here
-      std::pair<std::string, uint16_t> peerInfo;
-      socket->getPeerInfo(peerInfo);
-      e->poolSocket(peerInfo.first, peerInfo.second, socket);
+
+      poolConnection();
 
       return false;
     }
@@ -436,4 +436,13 @@ bool FtpNegotiationCommand::processSequence(const SegmentHandle& segment) {
   return doNextSequence;
 }
 
+void FtpNegotiationCommand::poolConnection() const
+{
+  if(e->option->getAsBool(PREF_FTP_REUSE_CONNECTION)) {
+    std::pair<std::string, uint16_t> peerInfo;
+    socket->getPeerInfo(peerInfo);
+    e->poolSocket(peerInfo.first, peerInfo.second, socket);
+  }
+}
+
 } // namespace aria2

+ 2 - 0
src/FtpNegotiationCommand.h

@@ -98,6 +98,8 @@ private:
 
   void afterFileAllocation();
 
+  void poolConnection() const;
+
   SharedHandle<SocketCore> dataSocket;
   SharedHandle<SocketCore> serverSocket;
   Seq sequence;