-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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); |
There was a problem hiding this comment.
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()
Use refreshNonce() instead now |
#34