chunks: fix aimd hanging with files less than chunk size
refs: #4439 Change-Id: Ie3ef5d81e6baf154ade97beda183bc6b16764085
This commit is contained in:
1 parent
2f041d20af
commit
034f30f27a
3 files changed
+41
-4
No files matched your search
@@ -496,6 +496,27 @@ BOOST_AUTO_TEST_CASE(PrintSummaryWithNoRttMeasurements)
|
||||
std::cerr.rdbuf(oldBuf); // reset
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(StopsWhenFileSizeLessThanChunkSize)
|
||||
{
|
||||
// test to see if the program doesn't hang,
|
||||
// when transfer is complete, for files less than the chunk size
|
||||
// (i.e. when only one segment is sent/received)
|
||||
|
||||
createPipeline();
|
||||
nDataSegments = 1;
|
||||
|
||||
runWithData(*makeDataWithSegment(0));
|
||||
advanceClocks(io, time::nanoseconds(1));
|
||||
|
||||
face.receive(*makeDataWithSegment(1));
|
||||
advanceClocks(io, time::nanoseconds(1));
|
||||
|
||||
BOOST_CHECK_EQUAL(aimdPipeline->m_hasFinalBlockId, true);
|
||||
BOOST_CHECK_EQUAL(aimdPipeline->m_segmentInfo.size(), 0);
|
||||
BOOST_CHECK_EQUAL(face.getNPendingInterests(), 0);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END() // TestPipelineInterestsAimd
|
||||
BOOST_AUTO_TEST_SUITE_END() // Chunks
|
||||
|
||||
|
||||
@@ -70,6 +70,14 @@ PipelineInterestsAimd::~PipelineInterestsAimd()
|
||||
void
|
||||
PipelineInterestsAimd::doRun()
|
||||
{
|
||||
if (allSegmentsReceived()) {
|
||||
cancel();
|
||||
if (!m_options.isQuiet) {
|
||||
printSummary();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// schedule the event to check retransmission timer
|
||||
m_checkRtoEvent = m_scheduler.scheduleEvent(m_options.rtoCheckInterval, [this] { checkRto(); });
|
||||
|
||||
@@ -121,7 +129,7 @@ PipelineInterestsAimd::sendInterest(uint64_t segNo, bool isRetransmission)
|
||||
if (isStopping())
|
||||
return;
|
||||
|
||||
if (m_hasFinalBlockId && segNo > m_lastSegmentNo && !isRetransmission)
|
||||
if (m_hasFinalBlockId && segNo > m_lastSegmentNo)
|
||||
return;
|
||||
|
||||
if (!isRetransmission && m_hasFailure)
|
||||
@@ -291,8 +299,7 @@ PipelineInterestsAimd::handleData(const Interest& interest, const Data& data)
|
||||
}
|
||||
|
||||
BOOST_ASSERT(m_nReceived > 0);
|
||||
if (m_hasFinalBlockId &&
|
||||
static_cast<uint64_t>(m_nReceived - 1) >= m_lastSegmentNo) { // all segments have been received
|
||||
if (allSegmentsReceived()) {
|
||||
cancel();
|
||||
if (!m_options.isQuiet) {
|
||||
printSummary();
|
||||
@@ -435,6 +442,12 @@ PipelineInterestsAimd::cancelInFlightSegmentsGreaterThan(uint64_t segNo)
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
PipelineInterestsAimd::allSegmentsReceived() const
|
||||
{
|
||||
return m_hasFinalBlockId && static_cast<uint64_t>(m_nReceived - 1) >= m_lastSegmentNo;
|
||||
}
|
||||
|
||||
void
|
||||
PipelineInterestsAimd::printSummary() const
|
||||
{
|
||||
@@ -442,7 +455,7 @@ PipelineInterestsAimd::printSummary() const
|
||||
std::cerr << "Total # of lost/retransmitted segments: " << m_nRetransmitted
|
||||
<< " (caused " << m_nLossEvents << " window decreases)\n"
|
||||
<< "Packet loss rate: "
|
||||
<< (static_cast<double>(m_nRetransmitted) / static_cast<double>(m_nSent)) * 100 << "%\n"
|
||||
<< (m_nSent == 0 ? 0 : (static_cast<double>(m_nRetransmitted) / static_cast<double>(m_nSent) * 100)) << "%\n"
|
||||
<< "Total # of received congestion marks: " << m_nCongMarks << "\n"
|
||||
<< "RTT ";
|
||||
|
||||
|
||||
@@ -184,6 +184,9 @@ private:
|
||||
void
|
||||
cancelInFlightSegmentsGreaterThan(uint64_t segNo);
|
||||
|
||||
bool
|
||||
allSegmentsReceived() const;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
void
|
||||
printSummary() const final;
|
||||
|
||||
Reference in new issue
Block a user