Browse Source

2009-10-31 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Fixed the bug that when downloading more than one torrent,
	listening port is not reported properly to tracker for 2nd or
	later torrents.
	* src/BtSetup.cc
	* src/PeerListenCommand.cc
	* src/PeerListenCommand.h
	* src/RequestGroup.cc
Tatsuhiro Tsujikawa 16 years ago
parent
commit
a71b642db1
5 changed files with 27 additions and 1 deletions
  1. 10 0
      ChangeLog
  2. 3 0
      src/BtSetup.cc
  3. 11 0
      src/PeerListenCommand.cc
  4. 3 0
      src/PeerListenCommand.h
  5. 0 1
      src/RequestGroup.cc

+ 10 - 0
ChangeLog

@@ -1,3 +1,13 @@
+2009-10-31  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Fixed the bug that when downloading more than one torrent,
+	listening port is not reported properly to tracker for 2nd or
+	later torrents.
+	* src/BtSetup.cc
+	* src/PeerListenCommand.cc
+	* src/PeerListenCommand.h
+	* src/RequestGroup.cc
+
 2009-10-29  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Bump up version number to 1.6.3

+ 3 - 0
src/BtSetup.cc

@@ -158,6 +158,9 @@ void BtSetup::setup(std::deque<Command*>& commands,
       _logger->error(_("Errors occurred while binding port.\n"));
       delete listenCommand;
     }
+  } else {
+    PeerListenCommand* listenCommand = PeerListenCommand::getInstance(e);
+    btRuntime->setListenPort(listenCommand->getPort());
   }
   time_t btStopTimeout = option->getAsInt(PREF_BT_STOP_TIMEOUT);
   if(btStopTimeout > 0) {

+ 11 - 0
src/PeerListenCommand.cc

@@ -96,6 +96,17 @@ bool PeerListenCommand::bindPort(uint16_t& port, IntSequence& seq)
   return false;
 }
 
+uint16_t PeerListenCommand::getPort() const
+{
+  if(socket.isNull()) {
+    return 0;
+  } else {
+    std::pair<std::string, uint16_t> addr;
+    socket->getAddrInfo(addr);
+    return addr.second;
+  }
+}
+
 bool PeerListenCommand::execute() {
   if(e->isHaltRequested() || e->_requestGroupMan->downloadFinished()) {
     return true;

+ 3 - 0
src/PeerListenCommand.h

@@ -67,6 +67,9 @@ public:
    */
   bool bindPort(uint16_t& port, IntSequence& seq);
 
+  // Returns binded port
+  uint16_t getPort() const;
+
   void setLowestSpeedLimit(unsigned int speed)
   {
     _lowestSpeedLimit = speed;

+ 0 - 1
src/RequestGroup.cc

@@ -233,7 +233,6 @@ void RequestGroup::createInitialCommand(std::deque<Command*>& commands,
 						       _option.get()));
         
       BtRuntimeHandle btRuntime(new BtRuntime());
-      btRuntime->setListenPort(_option->getAsInt(PREF_LISTEN_PORT));
       btRuntime->setMaxPeers(_option->getAsInt(PREF_BT_MAX_PEERS));
       _btRuntime = btRuntime;
       progressInfoFile->setBtRuntime(btRuntime);