Browse Source

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

	Added length equality test to operator== to drop a piece message
	whose length does not match to the requested one.
	* src/RequestSlot.cc
	* test/DefaultBtMessageDispatcherTest.cc
Tatsuhiro Tsujikawa 17 years ago
parent
commit
c0c80adaa2
3 changed files with 10 additions and 2 deletions
  1. 7 0
      ChangeLog
  2. 2 1
      src/RequestSlot.cc
  3. 1 1
      test/DefaultBtMessageDispatcherTest.cc

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2008-10-19  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Added length equality test to operator== to drop a piece message
+	whose length does not match to the requested one.
+	* src/RequestSlot.cc
+	* test/DefaultBtMessageDispatcherTest.cc
+	
 2008-10-19  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Fixed the bug that aria2 aborts when a request larger than 16KiB is

+ 2 - 1
src/RequestSlot.cc

@@ -68,7 +68,8 @@ RequestSlot& RequestSlot::operator=(const RequestSlot& requestSlot)
 
 bool RequestSlot::operator==(const RequestSlot& requestSlot) const
 {
-  return index == requestSlot.index && begin == requestSlot.begin;
+  return index == requestSlot.index && begin == requestSlot.begin
+    && length == requestSlot.length;
 }
 
 bool RequestSlot::operator!=(const RequestSlot& requestSlot) const

+ 1 - 1
test/DefaultBtMessageDispatcherTest.cc

@@ -399,7 +399,7 @@ void DefaultBtMessageDispatcherTest::testGetOutstandingRequest() {
   CPPUNIT_ASSERT(!RequestSlot::isNull(s2));
 
   RequestSlot s3 = btMessageDispatcher->getOutstandingRequest(1, 1024, 17*1024);
-  CPPUNIT_ASSERT(!RequestSlot::isNull(s3));
+  CPPUNIT_ASSERT(RequestSlot::isNull(s3));
 
   RequestSlot s4 = btMessageDispatcher->getOutstandingRequest(1, 2*1024, 16*1024);
   CPPUNIT_ASSERT(RequestSlot::isNull(s4));