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

Conversation

matianxing1992
Copy link
Contributor

#34

src/consumer.cpp Outdated Show resolved Hide resolved
src/consumer.cpp Outdated
@@ -270,7 +286,11 @@ Consumer::handleTimeout(const Interest& interest, int nRetrials,
{
if (nRetrials > 0) {
NDN_LOG_INFO("Timeout for: " << interest << ", retrying");
m_face.expressInterest(interest, dataCallback,
auto interestNew = const_cast<Interest&>(interest);
int factor = (int) std::pow(2, m_maxRetries+1-nRetrials);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use cast instead? Also m_maxRetries + 1 - nRetrials.

src/consumer.cpp Outdated
@@ -270,7 +286,11 @@ Consumer::handleTimeout(const Interest& interest, int nRetrials,
{
if (nRetrials > 0) {
NDN_LOG_INFO("Timeout for: " << interest << ", retrying");
m_face.expressInterest(interest, dataCallback,
auto interestNew = const_cast<Interest&>(interest);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite understand here. Why make an Interest then cast it into another?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A const interest's nonce can't be changed

Copy link
Contributor

@tianyuan129 tianyuan129 May 17, 2024

Choose a reason for hiding this comment

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

Then better make a new interest and copy over fields. This cast looks a bit strange to me tbh…solely for getting rid of const

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will make a new interest here.

@tianyuan129 tianyuan129 self-assigned this May 17, 2024
@matianxing1992
Copy link
Contributor Author

Made some changes accordingly and submitted a new commit

src/consumer.cpp Outdated
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()

@matianxing1992
Copy link
Contributor Author

Use refreshNonce() instead now

@tianyuan129 tianyuan129 merged commit 235bc2b into UCLA-IRL:master May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants