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

Changed method signature:
	SegmentMan::getInFlightSegment
	* src/AbstractCommand.cc
	* src/SegmentMan.cc
	* src/SegmentMan.h
	* test/SegmentManTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-05-11 10:46:52 +00:00
parent 83731bab5c
commit 82e0092b19
5 changed files with 20 additions and 10 deletions

View File

@ -1,3 +1,12 @@
2008-05-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed method signature:
SegmentMan::getInFlightSegment
* src/AbstractCommand.cc
* src/SegmentMan.cc
* src/SegmentMan.h
* test/SegmentManTest.cc
2008-05-11 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed method signature:

View File

@ -125,7 +125,8 @@ bool AbstractCommand::execute() {
(!checkSocketIsReadable && !checkSocketIsWritable && !nameResolverCheck)) {
checkPoint.reset();
if(!_requestGroup->getPieceStorage().isNull()) {
_segments = _requestGroup->getSegmentMan()->getInFlightSegment(cuid);
_segments.clear();
_requestGroup->getSegmentMan()->getInFlightSegment(_segments, cuid);
size_t maxSegments;
if(req->isPipeliningEnabled()) {
maxSegments = e->option->getAsInt(PREF_MAX_HTTP_PIPELINING);

View File

@ -147,17 +147,16 @@ SegmentEntryHandle SegmentMan::findSlowerSegmentEntry(const PeerStatHandle& peer
return slowSegmentEntry;
}
Segments SegmentMan::getInFlightSegment(int32_t cuid)
void SegmentMan::getInFlightSegment(std::deque<SharedHandle<Segment> >& segments,
int32_t cuid)
{
Segments temp;
for(SegmentEntries::iterator itr = usedSegmentEntries.begin();
itr != usedSegmentEntries.end(); ++itr) {
const SegmentEntryHandle& segmentEntry = *itr;
if(segmentEntry->cuid == cuid) {
temp.push_back(segmentEntry->segment);
segments.push_back(segmentEntry->segment);
}
}
return temp;
}
SegmentHandle SegmentMan::getSegment(int32_t cuid) {

View File

@ -110,11 +110,11 @@ public:
bool downloadFinished() const;
/**
* Returns a vacant segment.
* If there is no vacant segment, then returns a segment instance whose
* isNull call is true.
* Fill segments which are assigned to the command whose CUID is cuid.
* This function doesn't clear passed segments.
*/
std::deque<SharedHandle<Segment> > getInFlightSegment(int32_t cuid);
void getInFlightSegment(std::deque<SharedHandle<Segment> >& segments,
int32_t cuid);
SharedHandle<Segment> getSegment(int32_t cuid);

View File

@ -78,7 +78,8 @@ void SegmentManTest::testCompleteSegment()
seg->updateWrittenLength(pieceLength);
segmentMan.completeSegment(1, seg);
std::deque<SharedHandle<Segment> > segments = segmentMan.getInFlightSegment(1);
std::deque<SharedHandle<Segment> > segments;
segmentMan.getInFlightSegment(segments, 1);
CPPUNIT_ASSERT_EQUAL((size_t)2, segments.size());
CPPUNIT_ASSERT_EQUAL((size_t)0, segments[0]->getIndex());
CPPUNIT_ASSERT_EQUAL((size_t)2, segments[1]->getIndex());