Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the problem of duplicate nonce; Add APIs to set m_maxRetries and m_defaultTimeout #35

Merged
merged 3 commits into from
May 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/consumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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&>(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<int>(std::pow(2, m_maxRetries + 1 - nRetrials));
interestRetry.setCanBePrefix(true);
interestRetry.setInterestLifetime(ndn::time::milliseconds(m_defaultTimeout*factor));
interestRetry.setNonce(std::nullopt);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, you should use refreshNonce()

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));
Expand Down
Loading