From bf4d176c7ca00040a73daa3ebcc7fd4b3a65b74f Mon Sep 17 00:00:00 2001 From: matianxing1992 Date: Fri, 17 May 2024 12:06:33 -0500 Subject: [PATCH] Fix the issues in the PR --- src/consumer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/consumer.cpp b/src/consumer.cpp index 6bc58ca..62847a4 100644 --- a/src/consumer.cpp +++ b/src/consumer.cpp @@ -286,11 +286,12 @@ Consumer::handleTimeout(const Interest& interest, int nRetrials, { if (nRetrials > 0) { NDN_LOG_INFO("Timeout for: " << interest << ", retrying"); - auto interestNew = const_cast(interest); - int factor = (int) std::pow(2, m_maxRetries+1-nRetrials); - interestNew.setInterestLifetime(ndn::time::milliseconds(m_defaultTimeout*factor)); - interestNew.setNonce(std::nullopt); - m_face.expressInterest(interestNew, dataCallback, + Interest interestRetry(interest); + int factor = static_cast(std::pow(2, m_maxRetries + 1 - nRetrials)); + interestRetry.setCanBePrefix(true); + interestRetry.setInterestLifetime(ndn::time::milliseconds(m_defaultTimeout*factor)); + interestRetry.setNonce(std::nullopt); + m_face.expressInterest(interestRetry, dataCallback, std::bind(&Consumer::handleNack, this, _1, _2, errorCallback, nackMessage), std::bind(&Consumer::handleTimeout, this, _1, nRetrials - 1, dataCallback, errorCallback, nackMessage, timeoutMessage));