浏览代码

2007-07-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Fixed the bug that causes segfault when all URIs specified are
	unsupported.
	* src/RequestGroupMan.cc (getInitialCommands)
	Check if RequestGroup::createNextCommand() returns empty list of
	commands.
	* src/RequestGroup.cc (createNextCommand)
	Change log level from info to error so that users can notice 
that
	an error occurred.

	Fixed the bug that causes segfault when a zero-sized file is
	downloaded.
	* src/BitfieldMan.cc (isAllBitSet)
	Return true if bitfieldLength is 0.
Tatsuhiro Tsujikawa 18 年之前
父节点
当前提交
77a3820920
共有 4 个文件被更改,包括 25 次插入3 次删除
  1. 16 0
      ChangeLog
  2. 3 0
      src/BitfieldMan.cc
  3. 2 2
      src/RequestGroup.cc
  4. 4 1
      src/RequestGroupMan.cc

+ 16 - 0
ChangeLog

@@ -1,3 +1,19 @@
+2007-07-09  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Fixed the bug that causes segfault when all URIs specified are
+	unsupported.
+	* src/RequestGroupMan.cc (getInitialCommands)
+	Check if RequestGroup::createNextCommand() returns empty list of
+	commands.
+	* src/RequestGroup.cc (createNextCommand)
+	Change log level from info to error so that users can notice that
+	an error occurred.
+
+	Fixed the bug that causes segfault when a zero-sized file is
+	downloaded.
+	* src/BitfieldMan.cc (isAllBitSet)
+	Return true if bitfieldLength is 0.
+	
 2007-07-08  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	* src/main.cc

+ 3 - 0
src/BitfieldMan.cc

@@ -458,6 +458,9 @@ bool BitfieldMan::isFilteredAllBitSet() const {
 }
 
 bool BitfieldMan::isAllBitSet() const {
+  if(bitfieldLength == 0) {
+    return true;
+  }
   for(int32_t i = 0; i < bitfieldLength-1; ++i) {
     if(bitfield[i] != 0xff) {
       return false;

+ 2 - 2
src/RequestGroup.cc

@@ -80,8 +80,8 @@ Commands RequestGroup::createNextCommand(DownloadEngine* e, int32_t numCommand,
     if(req->setUrl(uri)) {
       commands.push_back(InitiateConnectionCommandFactory::createInitiateConnectionCommand(CUIDCounterSingletonHolder::instance()->newID(), req, this, e));
     } else {
-      logger->info(_("Unrecognized URL or unsupported protocol: %s\n"),
-		   req->getUrl().c_str());
+      logger->error(_("Unrecognized URL or unsupported protocol: %s\n"),
+		    req->getUrl().c_str());
     }
   }
   return commands;

+ 4 - 1
src/RequestGroupMan.cc

@@ -91,7 +91,10 @@ Commands RequestGroupMan::getInitialCommands(DownloadEngine* e)
 	itr != _requestGroups.end(); ++itr) {
     (*itr)->initSegmentMan();
     (*itr)->setGID(++_gidCounter);
-    commands.push_back((*itr)->createNextCommand(e, 1).front());
+    Commands nextCommands = (*itr)->createNextCommand(e, 1);
+    if(!nextCommands.empty()) {
+      commands.push_back(nextCommands.front());
+    }
   }
   return commands;
 }